Rig.TUnit.Microservices.Inbox
0.1.0-beta.2
dotnet add package Rig.TUnit.Microservices.Inbox --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Microservices.Inbox -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Microservices.Inbox" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Microservices.Inbox" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Microservices.Inbox" />
paket add Rig.TUnit.Microservices.Inbox --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Microservices.Inbox, 0.1.0-beta.2"
#:package Rig.TUnit.Microservices.Inbox@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Microservices.Inbox&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Microservices.Inbox&version=0.1.0-beta.2&prerelease
Rig.TUnit.Microservices.Inbox
Inbox pattern — per-aggregate sequence tracking for idempotent event application.
SequenceTracker+ fluentInboxAssert.SequenceApplied(…).Idempotent().
What this package is
The query-side idempotency helper for event-sourced microservices.
SequenceTracker keeps a per-aggregate "highest applied sequence"
record; TryApply(aggregateId, sequence) returns true only for
strictly-increasing sequences. Duplicates and out-of-order events are
rejected. InboxAssert offers the fluent assertion shape tests expect.
When to use it
- Testing event-handler idempotency.
- Verifying out-of-order events are rejected.
- Regression-guarding "at-least-once delivery" correctness after a consumer rewrite.
- Not for: integration testing of a real DB-backed inbox — extend
SequenceTrackerwith your persistence adapter.
Prerequisites
- .NET 10 SDK
Quick start
using Rig.TUnit.Microservices.Inbox;
var tracker = new SequenceTracker();
tracker.TryApply("agg-1", 5); // true
tracker.TryApply("agg-1", 5); // false — idempotent re-apply
tracker.TryApply("agg-1", 4); // false — out of order
InboxAssert.SequenceApplied(tracker, "agg-1", 5).Idempotent();
Options
| Property | Type | Default | Description |
|---|---|---|---|
MaxTrackedAggregates |
int |
10_000 |
Guard against unbounded growth |
EvictionPolicy |
InboxEvictionPolicy |
OldestFirst |
How to reclaim slots when full |
Fixture + helper APIs
Rig.TUnit.Microservices.Inbox.SequenceTrackerRig.TUnit.Microservices.Inbox.Assertions.InboxAssert
Per-test isolation
Each SequenceTracker instance is scoped per-test. No shared statics.
Safe under full parallelism.
Parallelism + performance
TryApplyis a dictionary lookup + CAS: ~50 ns per call.- Thread-safe via
ConcurrentDictionary; safe under full parallelism.
Troubleshooting
TryApplyreturnstruefor a duplicate — the aggregate-id string is different (case, whitespace).SequenceTrackeris case-sensitive by design; normalise at your persistence boundary.
See docs/troubleshooting.md#inbox.
Provider quirks + edge cases
- Sequence numbers are
long; negative sequences throwArgumentOutOfRangeException. - Gaps are not detected —
TryApply(5)afterTryApply(3)returnstrue, and the tracker advances. That is the correct semantic for most inbox patterns (gaps are the publisher's problem).
Benchmarks
See InboxBenchmarks.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.Inbox:
| 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 | 49 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 50 | 4/26/2026 |