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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SolTechnology.Core.HTTP.Testing" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SolTechnology.Core.HTTP.Testing" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SolTechnology.Core.HTTP.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SolTechnology.Core.HTTP.Testing --version 1.0.0
                    
#r "nuget: SolTechnology.Core.HTTP.Testing, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SolTechnology.Core.HTTP.Testing@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SolTechnology.Core.HTTP.Testing&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SolTechnology.Core.HTTP.Testing&version=1.0.0
                    
Install as a Cake Tool

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 (namespace SolTechnology.Core.FakerSolTechnology.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 port 0; read Url/Port to 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 WireMockServerSettings to WireMockStartup.Run(settings).
  • Reset() vs Dispose(). 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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