Rig.TUnit.Resilience 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Resilience.
dotnet add package Rig.TUnit.Resilience --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.Resilience -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.Resilience" 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.Resilience" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Resilience" />
                    
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.Resilience --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Resilience, 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.Resilience@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.Resilience&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Resilience&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.Resilience

Polly 8.x assertions + FakeTimeProvider-driven deterministic retry/backoff testing: CircuitBreakerAssert, RetryAssert, RateLimitAssert, BulkheadAssert, ChaosInjector.

What this package is

The Rig.TUnit kit for testing Polly-based resilience pipelines. Four fluent assertion families cover the four Polly strategies (CircuitBreaker, Retry, RateLimit, Bulkhead), each parameterisable against a CircuitBreakerStateProvider or equivalent. ResilienceClock wraps FakeTimeProvider so retries and breaker windows can be jumped over deterministically — no Thread.Sleep, no flake. ChaosInjector lets tests flip operations to fail on demand to exercise breaker / retry paths.

When to use it

  • Testing retry + circuit breaker policies end-to-end.
  • Verifying rate limits throttle when saturated.
  • Asserting bulkhead isolation prevents cascading failures.
  • Not for: unit-testing business logic — wrap your service with the real pipeline in an integration test.

Prerequisites

  • .NET 10 SDK
  • Polly 8.x + Polly.Extensions (transitive)
  • Microsoft.Extensions.TimeProvider.Testing (transitive)

Quick start

using Polly;
using Polly.CircuitBreaker;
using Rig.TUnit.Resilience;

var state = new CircuitBreakerStateProvider();
var pipeline = new ResiliencePipelineBuilder()
    .AddCircuitBreaker(new CircuitBreakerStrategyOptions
    {
        FailureRatio = 1.0,
        MinimumThroughput = 2,
        StateProvider = state,
    })
    .Build();

Options

Property Type Default Description
DefaultBreakDuration TimeSpan 30s Applied to breaker strategies
DefaultSamplingDuration TimeSpan 30s Breaker sampling window
ChaosFailureRate double 0.0 ChaosInjector.Execute failure probability

Fixture + helper APIs

  • Rig.TUnit.Resilience.CircuitBreakerAssert
  • Rig.TUnit.Resilience.RetryAssert
  • Rig.TUnit.Resilience.RateLimitAssert
  • Rig.TUnit.Resilience.BulkheadAssert
  • Rig.TUnit.Resilience.Helpers.ResilienceClock
  • Rig.TUnit.Resilience.Helpers.ChaosInjector

Per-test isolation

Each assertion is stateless; state providers + pipelines are per-test. ResilienceClock owns its own FakeTimeProvider per instance. Safe under full parallelism.

Parallelism + performance

  • Zero containers.
  • Per-assertion: microseconds plus the cost of pipeline execution.
  • Safe under full parallelism.

Troubleshooting

  • Retry backoff does not fire in tests — pipelines default to the system TimeProvider; inject ResilienceClock.TimeProvider into the ResiliencePipelineBuilder.TimeProvider property.
  • CircuitBreakerAssert.After(failures: N) reports wrong state — the breaker's MinimumThroughput was not met; tests must fire enough calls to satisfy the sampling threshold.

See docs/troubleshooting.md#resilience.

Provider quirks + edge cases

  • Polly 8.x breaking API change — ResiliencePipeline<T> replaces IAsyncPolicy<T>; assertions assume the new API.
  • Sampling-window math: MinimumThroughput + FailureRatio combine — FailureRatio=1.0, MinimumThroughput=5 means 5 consecutive failures in the sampling window trip the breaker.
  • Bulkhead is provided by Polly.RateLimiting in v8+ (no more separate Bulkhead strategy).

Benchmarks

See ResilienceBenchmarks.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 (1)

Showing the top 1 NuGet packages that depend on Rig.TUnit.Resilience:

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).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.2 53 4/27/2026
0.0.0-alpha.0.14 64 4/26/2026