-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does UsingMethod check _callscount? #815
Labels
Comments
@robvangeloven Because I cannot reproduce it in existing unit tests. And also not in new unit tests (#816) |
@StefH Sure! using System.Net;
using FluentAssertions;
using WireMock.FluentAssertions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
var server = WireMockServer.Start();
server
.Given(Request.Create().WithPath("/a").UsingGet())
.RespondWith(Response.Create().WithBodyAsJson("A response").WithStatusCode(HttpStatusCode.OK));
server
.Given(Request.Create().WithPath("/b").UsingPost())
.RespondWith(Response.Create().WithBodyAsJson("B response").WithStatusCode(HttpStatusCode.OK));
server
.Given(Request.Create().WithPath("/c").UsingPost())
.RespondWith(Response.Create().WithBodyAsJson("C response").WithStatusCode(HttpStatusCode.OK));
var httpClient = new HttpClient();
await httpClient.GetAsync($"{server.Url}/a");
await httpClient.PostAsync($"{server.Url}/b", new StringContent("B"));
await httpClient.PostAsync($"{server.Url}/c", new StringContent("C"));
server
.Should()
.HaveReceived(1)
.Calls()
.AtUrl($"{server.Url}/c")
.And
.UsingPost();
server.Stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When making this call:
My expectation is that this will work, but I get the error:
Expected _wireMockFixture.Server to have been called using method "POST", but didn't find it among the methods {"GET", "POST", "POST"}.
However, I'm trying to check that there was a singular call that matches the specifics of the assert. And there is, but the UsingPost also checks the _callsCount for number of "POST" used.
The text was updated successfully, but these errors were encountered: