Rig.TUnit.WebAPI
0.1.0-beta.2
dotnet add package Rig.TUnit.WebAPI --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.WebAPI -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.WebAPI" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.WebAPI" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.WebAPI" />
paket add Rig.TUnit.WebAPI --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.WebAPI, 0.1.0-beta.2"
#:package Rig.TUnit.WebAPI@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.WebAPI&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.WebAPI&version=0.1.0-beta.2&prerelease
Rig.TUnit.WebAPI
WebApplicationFactoryextensions,TestAuthHeaderBuilder, and problem-details assertion helpers for ASP.NET Core Web API testing.
What this package is
The HTTP counterpart to Rig.TUnit.Grpc. Extends Microsoft's
WebApplicationFactory<TEntryPoint> with a Rig-aware builder, a
TestAuthHeaderBuilder that crafts JWT / cookie / mTLS auth headers
matching the host's configured schemes, and ProblemDetailsAssert that
unpacks RFC 9457 responses for fluent assertion.
Together with Rig.TUnit.Http (for raw HttpClient scenarios) this covers
the full ASP.NET Core Web API surface.
When to use it
- Integration-testing an ASP.NET Core controller or minimal-API project.
- Asserting on
ProblemDetails-shaped error responses. - Authenticating test requests with the same JWT / cookie the real flow uses.
- Not for: pure gRPC services — use
Rig.TUnit.Grpc.
Prerequisites
- .NET 10 SDK
- Project under test has a public
Programentry point (top-level statements expose one implicitly since .NET 6).
Quick start
using Rig.TUnit.WebAPI.Helpers;
using Rig.TUnit.Core.Builder;
using Rig.TUnit.Core.Helpers;
var rig = new RigBuilder()
.WithIsolation(IsolationKey.FromExecutionContext())
.UseWebApi(cfg => cfg.ConfigureServices(s => s.AddLogging()))
.Build();
await using var _ = rig;
Options
| Property | Type | Default | Description |
|---|---|---|---|
Environment |
string |
"Testing" |
Sets IHostEnvironment.EnvironmentName. |
ContentRoot |
string? |
null |
Override for static-file-serving tests. |
DefaultAcceptLanguage |
string |
"en-US" |
Sets Accept-Language on the shared client. |
Fixture + helper APIs
Rig.TUnit.WebAPI.Builder.WebApiRigBuilder— CRTP builderRig.TUnit.WebAPI.Authentication.TestAuthHeaderBuilder— JWT / cookieRig.TUnit.WebAPI.Helpers.ProblemDetailsAssert— RFC 9457 assertion
Per-test isolation
Each WebApplicationFactory lives in its own TestServer; DI services are
fresh per test. Auth helpers generate test-only JWTs with the
IsolationKey-derived subject claim so logs are cross-correlatable.
Parallelism + performance
- Host startup: ~80 ms (
Program.csbuild + service graph). - First-request warm-up: ~10 ms; steady-state ~0.5 ms per call (in-memory).
- Safe under full parallelism.
Troubleshooting
Unauthorizeddespite a valid test JWT — confirm the signing key returned byTestAuthHeaderBuildermatches the one the host'sJwtBearerOptionsis configured with; they must share the same test certificate.- Test server cannot find
Program— top-level statements produce an implicitinternalProgramclass; add[assembly: InternalsVisibleTo("YourTests")]or declare an explicitpublic partial class Program;.
Provider quirks + edge cases
WebApplicationFactoryruns the host on aTestServer, not Kestrel — features that require the Kestrel feature-collection (connection-ID inspection, raw-socket access) will not work.- HTTP/2 and HTTP/3 negotiation is simulated — browsers talk HTTP/1.1 in tests regardless of the production config.
Benchmarks
See WebApiBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
Related docs
License
MIT. See LICENSE.
| 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
- Bogus (>= 35.6.1)
- Mediator.Abstractions (>= 3.0.2)
- Microsoft.AspNetCore.Mvc.Testing (>= 10.0.0)
- Rig.TUnit.Core (>= 0.1.0-beta.2)
- Rig.TUnit.Mediator (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Rig.TUnit.WebAPI:
| Package | Downloads |
|---|---|
|
Rig.TUnit.All
Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices). |
|
|
Rig.TUnit
Convenience meta-package bundling Core + Mediator + Grpc + WebAPI — the default entry point for most projects. Use Rig.TUnit.All only when you need every package. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta.2 | 45 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 59 | 4/26/2026 |