Rig.TUnit.Microservices.EventSourcing 0.1.0-beta.2

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

Rig.TUnit.Microservices.EventSourcing

Given/When/Then harness for event-sourced aggregates with AggregateAssert.Raised<T>().WithData(…) and EventCatalogueAssert for schema-evolution verification.

What this package is

The testing harness for event-sourced aggregates. EventSourcingHarness <TAggregate> lets you rehydrate an aggregate from a list of past events, execute a command, and assert on the events it raises. EventCatalogueAssert takes a declared catalogue (version → event-type list) and verifies the aggregate's rehydration path still accepts every historical event shape — the load-bearing check for additive schema evolution.

When to use it

  • Unit-testing an event-sourced aggregate.
  • Verifying schema-evolution compatibility after a new event version lands.
  • Not for: integration tests that require a real event store — layer with Rig.TUnit.Databases.NoSql.KurrentDb.

Prerequisites

  • .NET 10 SDK
  • Your aggregate exposes a Rehydrate(events) factory and a Pending / ClearPending raised-event pattern (or equivalent).

Quick start

using Rig.TUnit.Microservices.EventSourcing;

var harness = new EventSourcingHarness<Order>(
    rehydrate:   events => Order.Rehydrate(events),
    getRaised:   o => o.Pending,
    clearRaised: o => o.ClearPending());

harness.Given(new OrderCreated("O-1", 100m))
       .When(o => o.Approve())
       .Then(new OrderApproved("O-1"));

Options

Property Type Default Description
RequireExactEventOrder bool true Fail if raised event order does not match Then(…)
IgnoreEventMetadata bool true Scrub EventId / Timestamp in comparisons
CatalogueSourceType Type? null Optional EventCatalogue type for schema checks

Fixture + helper APIs

  • Rig.TUnit.Microservices.EventSourcing.EventSourcingHarness<TAggregate>
  • Rig.TUnit.Microservices.EventSourcing.Assertions.AggregateAssert
  • Rig.TUnit.Microservices.EventSourcing.Assertions.EventCatalogueAssert

Per-test isolation

Each harness instance owns its own aggregate state — no shared statics, no cross-test bleed. Safe under full parallelism.

Parallelism + performance

  • Harness construction: ~1 µs.
  • Rehydrate + apply: dominated by aggregate's own logic, typically sub-millisecond.
  • Safe under full parallelism.

Troubleshooting

  • Then(expected) fails with length mismatch — aggregate raised more or fewer events than expected. Strict mode is the default; switch to RequireExactEventOrder=false if the contract allows extras.
  • EventCatalogueAssert fails after version bump — a new event type was added to the code but not to the catalogue declaration; update both in lockstep.

See docs/troubleshooting.md#event-sourcing.

Provider quirks + edge cases

  • The harness does not persist events between When calls — each call reapplies the full event stream. Aggregates that cache state across calls break this assumption; see WithCarriedState opt-in.
  • Event IDs are typically scrubbed in comparisons because they are generated at raise-time; the IgnoreEventMetadata flag controls this.

Benchmarks

See EventSourcingBenchmarks.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.Microservices.EventSourcing:

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 46 4/27/2026
0.0.0-alpha.0.14 50 4/26/2026