In integration tests, asserting HttpResponseMessages can be a real challenge, especially since error messages are sometimes not very clear. NFluent is known for giving clear error messages.
TestableHttpClient.NFluent is designed to make it easier to check HttpResponseMessages and TestableHttpClients and give clear error messages.
For example when the following check fails:
Check.That(response).HasResponseHeader("Server");it will return the following message:
The checked response's headers does not contain the expected header.
The checked response's headers:
{"Connection"} (1 item)
The expected header:
["Server"]
The TestableHttpClient.NFluent has been deprecated and is no longer being maintained. The main reason for this is that I no longer use NFluent. If someone wants to continue developing this library, please feel free to contact me.
TestableHttpClient.NFluent is released as a NuGet packages and can be installed via the NuGet manager in VisualStudio or by running the following command on the command line:
dotnet add package TestableHttpClient.NFluent
var client = new HttpClient();
var result = await httpClient.GetAsync("https://httpbin.org/status/200");
Check.That(result).HasStatusCode(HttpStatusCode.OK).And.HasContentHeader("Content-Type", "*/json*");var handler = new TestableHttpMessageHandler();
var client = new HttpClient(handler);
_ = await httpClient.GetAsync("https://httpbin.org/status/200");
Check.That(handler).HasMadeRequestsTo("https://httpbin.org*").WithHttpMethod(HttpMethod.Get);- David Perfors - dnperfors
See also the list of contributors who participated in this project.
This project is released under the MIT license, see LICENSE.md for more information.