SolTechnology.Core.HTTP.Testing
1.0.0
dotnet add package SolTechnology.Core.HTTP.Testing --version 1.0.0
NuGet\Install-Package SolTechnology.Core.HTTP.Testing -Version 1.0.0
<PackageReference Include="SolTechnology.Core.HTTP.Testing" Version="1.0.0" />
<PackageVersion Include="SolTechnology.Core.HTTP.Testing" Version="1.0.0" />
<PackageReference Include="SolTechnology.Core.HTTP.Testing" />
paket add SolTechnology.Core.HTTP.Testing --version 1.0.0
#r "nuget: SolTechnology.Core.HTTP.Testing, 1.0.0"
#:package SolTechnology.Core.HTTP.Testing@1.0.0
#addin nuget:?package=SolTechnology.Core.HTTP.Testing&version=1.0.0
#tool nuget:?package=SolTechnology.Core.HTTP.Testing&version=1.0.0
SolTechnology.Core.HTTP.Testing
Integration-testing fixtures for SolTechnology.Core.HTTP consumers: a WireMock.Net-backed
WireMockFixture and a fluent fake-API DSL keyed off your generated HTTP client interfaces.
Reference from test projects only — not needed at runtime in production assemblies. Migrated from
SolTechnology.Core.Faker(namespaceSolTechnology.Core.Faker→SolTechnology.Core.HTTP.Testing) — an accepted breaking change. See ADR-008.
What's in the box
| Type | Purpose |
|---|---|
WireMockFixture |
Boots a WireMock server (dynamic port), registers fake APIs, hands out the Fake<T> DSL, exposes Url/Port/LogEntries, resets/stops the server. |
FakeApiBase |
Base class for a fake API. Derive once and implement the client interface — : FakeApiBase, IYourClient. |
IFakeApi |
Marker/registration contract consumed by the fixture. |
IFakeApiBuilderWithRequest<T> / IFakeApiBuilderWithResponse |
The fluent request/response builder seam. |
JsonResponseBuilderDecorator |
IResponseBuilder decorator adding WithBodyAsJson ergonomics. |
Usage
// 1. One-time setup (assembly-level [OneTimeSetUp]).
var wireMock = new WireMockFixture();
wireMock.Initialize(); // dynamic port (0) by default — never collides in parallel suites
wireMock.RegisterFakeApi(new GoogleFakeApi());
// Wire your HTTP client to the fake server's actual address (read it after Initialize):
configuration["HTTPClients:Google:BaseAddress"] = $"{wireMock.Url}/google/";
// 2. In a test — arrange via a DIRECT method call: full IntelliSense + compile-time argument checks.
wireMock.Fake<IGoogleHTTPClient>()
.WithRequest(x => x.GetLocationOfCity(cityName))
.WithResponse(r => r.WithSuccess().WithBodyAsJson(new { name = "Wrocław" }));
// Optional: assert the client actually called the fake.
Assert.That(wireMock.LogEntries, Is.Not.Empty);
// 3a. Between tests (per-test teardown) — clears mappings + recorded requests, keeps the server up.
wireMock.Reset();
// 3b. End of the fixture's life (one-time teardown) — stops the server and frees the port.
wireMock.Dispose();
A fake API derives from FakeApiBase and implements the client interface — the interface is named
once (FakeApiBase is not generic). WithRequest invokes the method directly (no reflection), so
the method body sets up the matcher:
public class GoogleFakeApi : FakeApiBase, IGoogleHTTPClient
{
protected override string BaseUrl => "google"; // relative path segment matched on the server
public Task<City> GetLocationOfCity(string cityName)
{
var request = Request.Create().UsingGet()
.WithPath(new WildcardMatcher($"/{BaseUrl}/maps/api/geocode/json"))
.WithParam("address", cityName);
Provider = BuildRequest(request);
return default!;
}
}
Notes for large / parallel suites
- Dynamic port by default.
Initialize()binds port0; readUrl/Portto wire clients. Pass a fixed port only when a consumer hard-codes the address. - Admin interface off, no console logging by default (quiet under thousands of requests). Override by
passing your own
WireMockServerSettingstoWireMockStartup.Run(settings). Reset()vsDispose().Reset()is the between-test cleanup (mappings + recorded requests);Dispose()stops the server and frees the port — call it once at the end.- One fixture per test assembly, arranged sequentially. The arrangement DSL (
Fake<T>().WithRequest(...)) is not designed for concurrent arrangement of the same fake; keep arrangement on the test thread.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- SolTechnology.Core.Testing (>= 1.0.0)
- WireMock.Net (>= 2.11.0)
- WireMock.Net.StandAlone (>= 2.11.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 57 | 7/6/2026 |