Closed kiquenet closed 2 years ago
Please see https://github.com/WireMock-Net/WireMock.Net/wiki/Using-WireMock-in-UnitTests
In your case
var joke = new ChuckNorrisJoke
{
};
_server
.Given(Request.Create().WithPath("/jokes/random").UsingGet())
.RespondWith(
Response.Create()
.WithStatusCode(200)
.WithBodyAsJson(joke)
);
@kiquenet is this clear?
Only useful references:
HttpClient and testing https://adamstorr.azurewebsites.net/blog/test-your-dotnet-httpclient-based-strongly-typed-clients-like-a-boss
IHttpClientFactory vs HttpClient https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
YOU'RE USING HTTPCLIENT WRONG AND IT IS DESTABILIZING YOUR SOFTWARE
Thanks for these references, I know these, but this is not really applicable to WireMock.Net, it;s more applicable to the client code which calls the external api / calls WireMock.Net
How-to do unit testing for external API (like Fake API ) api.chucknorris.io ?
simple-example-of-calling-rest-api-with-httpclient-in-net5.0