Closed anjoiype closed 4 years ago
Hello @anjoiype How to you set the new mapping? Via C# code or by posting to __admin endpoint?
I set the new mapping via C# code.
_testContext.MockServer .Given(Request.Create() .WithPath($"/foo/bar")) .RespondWith(Response.Create() .WithStatusCode(200) .WithBodyFromFile(fooPath));
Here _testContext
is injected through DI and it contains WireMockServer.Start()
When using that code, a new mapping is added. So you end up with 2 mappings.
If you want to replace it, add a GUID when adding the first mapping.
And use the same GUID when adding the new one. See https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs#L169
It works now. Thanks a lot for wonderful support.
I have a requirement that on calling same path, each time I have to get separate response. It is not related to stateful behavior. When I try to set the response 2nd time, its not overwriting the first and hence getting the old response. If I reset the mappings, it will reset the whole mappings which I don't need. How to overwrite the response for same request?