All notable changes to TestableHttpClient.NFluent will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.8 - 2022-11-08
TestableHttpMessageHandler.SimulateTimeoutis deprecated, and can be replaced withRespondWith(Responses.Timeout()).TestableHttpMessageHandler.RespondWith(Func<HttpRequestMessage, HttpResponseMessage>)had been deprecated, it's functionality is replaced by IResponse.RespondWith(this TestableHttpMessageHandler, HttpResponseMessage)has been deprecated, the response is modified with every call, so it doesn't work reliably and is different from how HttpClientHandler works, which creates a HttpResponseMessage for every request.HttpResponseMessageBuilderandRespondWith(this TestableHttpMessageHandler, HttpResponseMessageBuilder)has been deprecated, it's functionality can be replaced with ConfiguredResponse or a custom IResponse.HttpRequestMessageExtensionsandHttpResponseMessageExtensionswere introduced as extensions for easier assertion. However, these types are intended for internal use and will be made internal next release.- TestableHttpClient.NFluent is deprecated and will be removed in the next version.
CreateClientnow acceptsDelegateHandlersin order to chain Handlers. The InnerHandler property of each handler is set automatically and theTestableHttpMessageHandleris automatically set as the last handler. This is showcased with Polly in the integration tests.- Added support for .NET Framework 4.6.2, .NET Framework 4.7 and .NET Framework 4.8 by running the tests against these versions.
- Added support for .NET 7
- When validating requests, an
HttpRequestMessageAssertionExceptionwill be thrown when the content of a request is disposed. This typically happens on .NET Framework when the runtime decides to use the older version of System.Net.Http. - Added several
Responses, includingDelayed,Timeout,Configured,Sequenced,StatusCodeandJson. These responses can now be used inside theRespondWith. - Added the possibility to set and override the JsonSerializerOptions.
TestableHttpClientnow works with theResponsesclass, making it easier to configure responses.- When
HttpResponseMessage.Contentis null afterIResponse.ExecuteAsyncwas called, an emptyStringContentis added (Up until .NET 6.0, since Content is always filled there). - The
HttpRequestMessageis always added to the response, which is now possible, since we no longer allow reusing responses. - Added
ConfigureAwait(false)to all calls, since we now use async/await in the library. - The check on request uri is now case insensitive by default, when test url's that are case sensitive set the
ignoreCaseparameter to false. - The project has been moved to an organisation, so all the url's have been changed and an icon is added to the NuGet package.
0.7 - 2022-09-22
- In 0.6 the debug symbols were embedded in the dll, so the pipeline couldn't upload the symbol package. This is corrected in 0.7 where the symbol package is correct.
- TestableHttpClient assembly is now CLSCompliant
- The mediaType parameter in
HttpResponseMessageBuilder.WithStringContentis no longer nullable, like in .NET 7.0, it defaults to "text/plain" in other methods. TestableHttpMessageHanlder.SimulateTimeoutfunctionality now actually cancels the request, so that it also works on .NET 7.0
- Support for .NET 6.0 has been added, although there were no code changes in the library, we now test if TestableHttpClient works with .NET 6.0. Besides that all assemblies are compiled using the .NET 6.0 SDK.
- The NuGet packages now support multiple target frameworks: .NET Standard 2.0, .NET Core 3.1 and .NET 6.0
- Support for .NET Core 2.1 has been removed, although there were no code changes in the library, we no longer test if TestableHttpClient works with .NET Core 2.1.
- Support for .NET 5 has been removed, although there were no code changes in the library, we no longer test if TestableHttpClient works with .NET Core 5
ShouldNotHaveMadeRequests(this TestableHttpMessageHandler)was removed in favour of the newShouldHaveMadeRequests(this HttpMessageHandler, 0).ShouldNotHaveMadeRequestsTo(this TestableHttpMessageHandler, string)was removed in favour of the newShouldHaveMadeRequestsTo(this HttpMessageHandler, string, 0).
0.6 - 2021-02-24
ShouldNotHaveMadeRequests(this TestableHttpMessageHandler)will be removed in favour of the newShouldHaveMadeRequests(this HttpMessageHandler, 0).ShouldNotHaveMadeRequestsTo(this TestableHttpMessageHandler, string)will be removed in favour of the newShouldHaveMadeRequestsTo(this HttpMessageHandler, string, 0).
WithQueryString(this IHttpRequestMessageCheck, string)to test the querystring without url encoding.RespondWith(Func<HttpRequestMessage, HttpResponseMessage)to configure a factory method that is called when making a request.ShouldHaveMadeRequests(this TestableHttpMessageHandler, int)to test that a certain amount of requests are made.ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, int)to test that a certain amount of requests are made.public static IHttpRequestMessagesCheck HasMadeRequests(this ICheck<TestableHttpMessageHandler?>, int)to test that a certain amount of requests are made.public static IHttpRequestMessagesCheck HasMadeRequestsTo(this ICheck<TestableHttpMessageHandler?>, string, int)to test that a certain amount of requests are made.
-
Debug symbols are now embedded in the dll and the snupkg file is no longer uploaded seperately.
-
TestableHttpClient is now being tested against multiple .net versions, currently these are: .NET Core 2.1, .NET Core 3.1 and .NET 5.0.
-
HasContent()andHasContent(string)now returnfalsewhen the actual content results in an empty string. -
Downgraded
System.Test.JsonandNFluentto the lowest supported version in the library. This is done based on the guidelines of Microsoft. -
Moved
RespondWith(HttpResponseMessage)to an extension method, since it now usesRespondWith(Func<HttpRequestMessage, HttpResponseMessage>). -
Moved
RespondWith(Action<HttpResponseMessageBuilder>)to an extension method, since it now usesRespondWith(Func<HttpRequestMessage, HttpResponseMessage>). -
Moved
SimulateTimeout()to an extension method, since it now usesRespondWith(Func<HttpRequestMessage, HttpResponseMessage>). -
The default response now sets the
HttpResponseMesage.RequestMessage. -
RespondWith(Action<HttpResponseMessageBuilder>)setsHttpResponseMessage.RequestMessageby default before calling the builder action. -
Build pipeline now uses .NET SDK by default including NETAnalyzers and C# 9
-
Build uses NerdBank.GitVersioning instead of GitVersion, since we have to specify the version number in the CHANGELOG.md anyways.
WithUriPattern(this IHttpRequestMessagesCheck, string)was removed in favour ofWithRequestUri(this IHttpRequestMessagesCheck, string)With(Func<HttpRequestMessage, bool>, string)was removed in favour ofWithFilter(Func<HttpRequestMessage, bool>, string), since it conflicts with the language keywordwith.Times(int)was removed in favour of theWith*methods with anintparameter.
0.5 - 2020-06-25
WithUriPattern(this IHttpRequestMessagesCheck, string)will be removed in favour ofWithRequestUri(this IHttpRequestMessagesCheck, string)With(Func<HttpRequestMessage, bool>, string)will be removed in favour ofWithFilter(Func<HttpRequestMessage, bool>, string), since it conflicts with the language keywordwith.Times(int)will be removed in favour of theWith*methods with anintparameter.
- It is now possible to use NFluent to check
TestableHttpMessageHandlerby usingCheck.That(handler).HasMadeRequests()andCheck.That(handler).HasMadeRequestsTo("https://github.com/testablehttpclient/testablehttpclient"). All existingWithchecks are supported. - All
With*methods got an extra overload to specify the exact number of expected requests. This is instead of theTimesmethod.
- Introduced
IHttpRequestMessagesCheckas the public interface for all checks on requests made toTestableHttpMessageHandler. It contains the following api:WithFilter(Func<HttpRequestMessage, bool>, string)WithFilter(Func<HttpRequestMessage, bool>, int, string)WithFilter(Func<HttpRequestMessage, bool>, int?, string)
- Moved some api's from
TestableHttpMessageHandlertoTestableHttpMessageHandlerAssertionExtensions:ShouldHaveMadeRequests(this TestableHttpMessageHandler)ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string)ShouldNotHaveMadeRequests(this TestableHttpMessageHandler)ShouldNotHaveMadeRequestsTo(this TestableHttpMessageHandler, string)
- Moved most methods from
HttpRequestMessageAssertertoHttpRequestMessagesCheckExtensions:WithRequestUri(this IHttpRequestMessagesCheck, string)which is renamed fromWithUriPattern(this IHttpRequestMessagesCheck, string)WithHttpMethod(this IHttpRequestMessagesCheck, HttpMethod)WithHttpVersion(this IHttpRequestMessagesCheck, Version)WithRequestHeader(this IHttpRequestMessagesCheck, string)WithRequestHeader(this IHttpRequestMessagesCheck, string, string)WithContentHeader(this IHttpRequestMessagesCheck, string)WithContentHeader(this IHttpRequestMessagesCheck, string, string)WithHeader(this IHttpRequestMessagesCheck, string)WithHeader(this IHttpRequestMessagesCheck, string, string)WithContent(this IHttpRequestMessagesCheck, string)WithJsonContent(this IHttpRequestMessagesCheck, object)WithFormUrlEncodedContent(this IHttpRequestMessagesCheck, IEnumerable<KeyValuePair<string, string>)
HttpRequestMessageAsserteris made internal.
0.4 - 2020-05-26
- the following deprecated api's are removed:
HttpResponseMessageBuilder.WithVersion(Version)HttpResponseMessageBuilder.WithStatusCode(HttpStatusCode)HttpResponseMessageBuilder.WithHeaders(Actions<HttpResponseHeaders>)HttpResponseMessageBuilder.WithHeader(string, string)HttpResponseMessageExtensions.HasHttpVersion(HttpResponseMessage, string)
TestableHttpMessageHandlerExtensions.CreateClient(TestableHttpMessageHandler)TestableHttpMessageHandlerExtensions.CreateClient(TestableHttpMessageHandler, Action<HttpClient>)
- Example on how to configure IHttpClientFactory now uses dependency injection, just how you would use it in real life.
0.3 - 2020-05-24
- Examples on how to use TestableHttpClient in combination with IHttpClientFactory. Note that this is revised in the next release.
HttpRequestMessageExtensions.HasContent(HttpRequestMessage)HttpResponseMessageExtensions.HasContent(HttpResponseMessage)
- Improve error messages in NFluent checks
- Improve release pipeline
- Renamed several api's:
HttpResponseMessageBuilder.WithVersion(Version)is renamed toWithHttpVersion(Version)HttpResponseMessageBuilder.WithStatusCode(HttpStatusCode)is renamed toWithHttpStatusCode(HttpStatusCode)HttpResponseMessageBuilder.WithHeaders(Actions<HttpResponseHeaders>)is renamed toWithResponseHeaders(Actions<HttpResponseHeaders>)HttpResponseMessageBuilder.WithHeader(string, string)is renamed toWithResponseHeader(string, string)
- the following api's are deprecated because they are renamed:
HttpResponseMessageBuilder.WithVersion(Version)HttpResponseMessageBuilder.WithStatusCode(HttpStatusCode)HttpResponseMessageBuilder.WithHeaders(Actions<HttpResponseHeaders>)HttpResponseMessageBuilder.WithHeader(string, string)
- the following api is deprecated because it is inconsistent:
HttpResponseMessageExtensions.HasHttpVersion(HttpResponseMessage, string)
0.2 - 2020-05-10
- TestableHttpClient.NFluent project. This project provides NFluent checks to check HttpResponseMessages. The following checks can be used:
HasHttpStatusCode(ICheck<HttpResponseMessage>, HttpStatusCode)HasReasonPhrase(ICheck<HttpResponseMessage>, string)HasHttpVersion(ICheck<HttpResponseMessage>, Version)HasResponseHeader(ICheck<HttpResponseMessage>, string)HasResponseHeader(ICheck<HttpResponseMessage>, string, string)HasContentHeader(ICheck<HttpResponseMessage>, string)HasContentHeader(ICheck<HttpResponseMessage>, string, string)HasContent(ICheck<HttpResponseMessage>)HasContent(ICheck<HttpResponseMessage>, string)
HttpResponseMessageExtensionsto easily check information onHttpResponseMessagesHasHttpVersion(HttpResponseMessage, Version)HasHttpVersion(HttpResponseMessage, string)HasHttpStatusCode(HttpResponseMessage, HttpStatusCode)HasReasonPhrase(HttpResponseMessage, string)HasResponseHeader(HttpResponseMessage, string)HasResponseHeader(HttpResponseMessage, string, string)HasContentHeader(HttpResponseMessage, string)HasContentHeader(HttpResponseMessage, string, string)HasContent(HttpResponseMessage, string)
0.1 - 2020-03-26
TestableHttMessageHandlerto record all requests that are made with anHttpClientRespondWith(HttpResponseMessage)RespondWith(Action<HttpResponseMessageBuilder>)SimulateTimeout()ShouldHaveMadeRequests()ShouldHaveMadeRequestsTo(string)ShouldNotHaveMadeRequests()ShouldNotHaveMadeRequestsTo(string)
HttpResponseMessageBuilderfor creating HttpResponseMessages in a fluent wayWithVersion(Version)WithStatusCode(HttpStatusCode)WithHeaders(Action<HttpResponseHeaders>)WithHeader(string, string)WithContent(HttpContent)WithStringContent(string)WithStringContent(string, Encoding)WithStringContent(string, Encoding, string)WithJsonContent(object)WithJsonContent(object, string)WithRequestMessage(HttpRequestMessage)Build()
HttpRequestMessageAsserterto validate that certain requests are made. This can be requested by callingTestableHttpMessageHandler.ShouldHaveMadeRequests()orTestableHttpMessageHandler.ShouldHaveMadeRequestsTo(string). The following methods are available:With(Func<HttpRequestMessage, bool>, string)WithUriPattern(string)WithHttpMethod(HttpMethod)WithHttpVersion(Version)WithRequestHeader(string)WithRequestHeader(string, string)WithContentHeader(string)WithContentHeader(string, string)WithHeader(string)WithHeader(string, string)WithContent(string)WithJsonContent(object)WithFormUrlEncodedContent(IEnumerable<KeyValuePair<string, string>>)Times(int)
HttpRequestMessageExtensionswith extension methods for testing a data on HttpRequestMessagesHasHttpVersion(HttpRequestMessage, Version)HasHttpVersion(HttpRequestMessage, string)HasHttpMethod(HttpRequestMessage, HttpMethod)HasHttpMethod(HttpRequestMessage, string)HasRequestMessage(HttpRequestMessage, string)HasRequestMessage(HttpRequestMessage, string, string)HasContentMessage(HttpRequestMessage, string)HasContentMessage(HttpRequestMessage, string, string)HasMatchingUri(HttpRequestMessage, string)HasContent(HttpRequestMessage, string)
- Created an integrationtest project that showcases all the basic features
- Created readme file
- Automatically build project when pushing changes to github and when creating a pull request
- Automatically deploy to NuGet when creating a tag in github