Enhanced.Testing.Component.WireMock
1.4.0
See the version list below for details.
dotnet add package Enhanced.Testing.Component.WireMock --version 1.4.0
NuGet\Install-Package Enhanced.Testing.Component.WireMock -Version 1.4.0
<PackageReference Include="Enhanced.Testing.Component.WireMock" Version="1.4.0" />
<PackageVersion Include="Enhanced.Testing.Component.WireMock" Version="1.4.0" />
<PackageReference Include="Enhanced.Testing.Component.WireMock" />
paket add Enhanced.Testing.Component.WireMock --version 1.4.0
#r "nuget: Enhanced.Testing.Component.WireMock, 1.4.0"
#:package Enhanced.Testing.Component.WireMock@1.4.0
#addin nuget:?package=Enhanced.Testing.Component.WireMock&version=1.4.0
#tool nuget:?package=Enhanced.Testing.Component.WireMock&version=1.4.0
Enhanced.Testing.Component.WireMock
A WireMock.Net harness for Enhanced.Testing.Component: fakes external HTTP APIs with an in-process server instead of calling real services. No Docker needed.
dotnet add package Enhanced.Testing.Component.WireMock
Usage
var quotesApi = new WireMockHarness { ConfigurationKey = "QuotesApi:BaseUrl" };
var component = ComponentBuilder.Create<Program>()
.AddHarness(quotesApi)
.AddHarness(http)
.Build();
The server starts with the component on a free port, and its URL is passed to the application as the
QuotesApi:BaseUrl setting. Point the application's HttpClient at that setting.
In a test, stub the external API, call the application, and verify the calls:
quotesApi.Server
.Given(Request.Create().WithPath("/quote").UsingGet())
.RespondWith(Response.Create().WithStatusCode(200).WithBody("Stay hungry"));
var response = await http.CreateClient().GetStringAsync("/quote");
Assert.Equal("Stay hungry", response);
Assert.Single(quotesApi.Server.LogEntries);
Serveris theWireMockServer, for stubbing and verification.Reset()removes stubs, scenarios and the request log; call it between tests that share the harness.BaseAddressandCreateClient()give the test the server's address or anHttpClientfor it.ConfigureServercustomizes theWireMockServerSettingsbefore the server starts.
The package depends on WireMock.Net.Minimal. Add the full WireMock.Net package if you need its extra matchers
(GraphQL, ProtoBuf).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Enhanced.Testing.Component (>= 1.4.0)
- WireMock.Net.Minimal (>= 2.31.0)
-
net11.0
- Enhanced.Testing.Component (>= 1.4.0)
- WireMock.Net.Minimal (>= 2.31.0)
-
net8.0
- Enhanced.Testing.Component (>= 1.4.0)
- WireMock.Net.Minimal (>= 2.31.0)
-
net9.0
- Enhanced.Testing.Component (>= 1.4.0)
- WireMock.Net.Minimal (>= 2.31.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.