Rig.TUnit.Microservices.Snapshots
0.1.0-beta.2
dotnet add package Rig.TUnit.Microservices.Snapshots --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Microservices.Snapshots -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Microservices.Snapshots" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Microservices.Snapshots" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Microservices.Snapshots" />
paket add Rig.TUnit.Microservices.Snapshots --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Microservices.Snapshots, 0.1.0-beta.2"
#:package Rig.TUnit.Microservices.Snapshots@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Microservices.Snapshots&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Microservices.Snapshots&version=0.1.0-beta.2&prerelease
Rig.TUnit.Microservices.Snapshots
Snapshot-testing assertion compatible with Verify.TUnit file naming, with microservice-opinionated scrubbers.
What this package is
A lightweight snapshot-testing harness compatible with Verify.TUnit
file-naming convention ({name}.received.* / {name}.verified.*).
What it adds on top is an opinionated, microservice-shaped scrubber
pipeline: correlation/causation IDs, event IDs, timestamps, sequence
numbers, connection strings, and filesystem paths become deterministic
placeholders before comparison. Without this, every snapshot test would
drift on every run.
When to use it
- Asserting the exact JSON shape of a REST / gRPC response.
- Verifying event-envelope layouts match the documented contract.
- Regression-guarding refactors that should preserve output byte-for-byte.
- Not for: live file-system state —
SnapshotAssertis for structured value comparison.
Prerequisites
- .NET 10 SDK
Verify.TUnit(transitive)
Quick start
using Rig.TUnit.Microservices.Snapshots;
var payload = new { Id = Guid.NewGuid(), At = DateTimeOffset.UtcNow, Total = 42 };
var result = await SnapshotAssert.MatchJson(
payload, name: "order-created", directory: "__snapshots__");
Options
| Property | Type | Default | Description |
|---|---|---|---|
AutoVerify |
bool |
false |
First-run auto-create {name}.verified.* (off by default — review) |
ScrubExtraPatterns |
string[]? |
null |
Extra regex patterns to scrub beyond defaults |
DiffOnFailure |
bool |
true |
Include line-diff in exception message |
Fixture + helper APIs
Rig.TUnit.Microservices.Snapshots.SnapshotAssertRig.TUnit.Microservices.Snapshots.Scrubbers.DefaultScrubbersRig.TUnit.Microservices.Snapshots.Options.SnapshotOptions
Per-test isolation
Snapshot files are named by the name argument + the test file's
directory — tests cannot collide by design. Verify.TUnit's naming
convention is preserved.
Parallelism + performance
- Per-assertion: ~1 ms for a ~1 KB payload (serialise + scrub + file compare).
- Safe under full parallelism — file I/O is per-test scoped.
Troubleshooting
- Snapshot drifts every run — a scrubber missed a volatile field.
Add it via
ScrubExtraPatternsor file a bug if it looks like a common shape. SnapshotAssertionException— inspect the.received.*file side-by-side with.verified.*; the exception message includes a line-diff by default.
See docs/troubleshooting.md#snapshots.
Provider quirks + edge cases
- Default scrubbers: GUID, ISO-8601 timestamp,
CorrelationId/CausationIdvalues,EventId/MessageId,Sequencenumeric, SQL Server connection strings, Windows/Unix absolute paths. Each is replaced with a deterministic placeholder. - Scrubbers are applied in order; later scrubbers see placeholders written by earlier ones.
- JSON property order is preserved — snapshot mismatches triggered by reordering are considered intentional.
Benchmarks
See SnapshotsBenchmarks.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)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Rig.TUnit.Core (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Rig.TUnit.Microservices.Snapshots:
| 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.Microservices
Meta-package: Core + Mediator + Grpc + Outbox + Tracing + Jwt + Seq — the opinionated microservice testing kit. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta.2 | 43 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 43 | 4/26/2026 |