Rig.TUnit.WebAPI 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.WebAPI.
dotnet add package Rig.TUnit.WebAPI --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.WebAPI -Version 0.1.0-beta.2
                    
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="Rig.TUnit.WebAPI" Version="0.1.0-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rig.TUnit.WebAPI" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.WebAPI" />
                    
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 Rig.TUnit.WebAPI --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.WebAPI, 0.1.0-beta.2"
                    
#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 Rig.TUnit.WebAPI@0.1.0-beta.2
                    
#: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=Rig.TUnit.WebAPI&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.WebAPI&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.WebAPI

WebApplicationFactory extensions, 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 Program entry 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 builder
  • Rig.TUnit.WebAPI.Authentication.TestAuthHeaderBuilder — JWT / cookie
  • Rig.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.cs build + service graph).
  • First-request warm-up: ~10 ms; steady-state ~0.5 ms per call (in-memory).
  • Safe under full parallelism.

Troubleshooting

  • Unauthorized despite a valid test JWT — confirm the signing key returned by TestAuthHeaderBuilder matches the one the host's JwtBearerOptions is configured with; they must share the same test certificate.
  • Test server cannot find Program — top-level statements produce an implicit internal Program class; add [assembly: InternalsVisibleTo("YourTests")] or declare an explicit public partial class Program;.

See docs/troubleshooting.md.

Provider quirks + edge cases

  • WebApplicationFactory runs the host on a TestServer, 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.

License

MIT. See LICENSE.

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 (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