TestableHttpClient 0.1.0
See the version list below for details.
dotnet add package TestableHttpClient --version 0.1.0
NuGet\Install-Package TestableHttpClient -Version 0.1.0
<PackageReference Include="TestableHttpClient" Version="0.1.0" />
paket add TestableHttpClient --version 0.1.0
#r "nuget: TestableHttpClient, 0.1.0"
// Install TestableHttpClient as a Cake Addin #addin nuget:?package=TestableHttpClient&version=0.1.0 // Install TestableHttpClient as a Cake Tool #tool nuget:?package=TestableHttpClient&version=0.1.0
Using HttpClient in code that is unit tested is seen as rather difficult, this library aims to make it easier to assert the calls that are made via an HttpClient.
How to install
This library is released as a NuGet package and can be installed via the NuGet manager in Visual Studio or by running the following command:
dotnet add package TestableHttpClient
How to use
var testHandler = new TestableHttpMessageHandler();
var httpClient = new HttpClient(testHandler);
var result = await httpClient.GetAsync("http://httpbin.org/status/200");
testHandler.ShouldHaveMadeRequestsTo("https://httpbin.org/*");
More examples can be found in the IntegrationTests project
Contributing
Please read CONTRIBUTING.md for details on how you can help us out.
Versioning
We use SemVer for versioning. For the versions available, see the releases on this repository.
Authors
- David Perfors - dnperfors
See also the list of contributors who participated in this project.
License
This project is released under the MIT license, see LICENSE.md for more information.
Acknowledgments
This library is largely inspired by the HttpTest functionality from Flurl.
A lot of the ideas came from the thread about unit testing HttpClient code in this dotnet issue.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 4.7.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TestableHttpClient:
Package | Downloads |
---|---|
TestableHttpClient.NFluent
NFluent checks for checking HttpResponseMessages. |
GitHub repositories
This package is not used by any popular GitHub repositories.