Stratara.Testing
3.2.1
dotnet add package Stratara.Testing --version 3.2.1
NuGet\Install-Package Stratara.Testing -Version 3.2.1
<PackageReference Include="Stratara.Testing" Version="3.2.1" />
<PackageVersion Include="Stratara.Testing" Version="3.2.1" />
<PackageReference Include="Stratara.Testing" />
paket add Stratara.Testing --version 3.2.1
#r "nuget: Stratara.Testing, 3.2.1"
#:package Stratara.Testing@3.2.1
#addin nuget:?package=Stratara.Testing&version=3.2.1
#tool nuget:?package=Stratara.Testing&version=3.2.1
Stratara.Testing
Test doubles and assertion helpers for applications built on the Stratara framework. Unit-test your event-sourced aggregates, encryption, messaging, and session-aware code without spinning up Postgres or RabbitMQ testcontainers.
Contents
AggregateTestHarness<T>/Aggregate.Rehydrate<T>(...)— given/when/then rehydration of an aggregate from events, using the sameApply(...)dispatch as production. Throws on an unmapped event so a forgotten overload fails the test (opt out withIgnoringUnmappedEvents()).InMemoryKeyStore— anIKeyStorethat mints random 256-bit DEKs per scope and supports rotation / revocation / scope-erasure, without a master KEK or key file.TestBlobEncryptor.CreateAesGcm()— the real AES-GCMISecureBlobEncryptorover anInMemoryKeyStore, so blob round-trips exercise production encryption.InMemoryMessageBus— anIMessageBuswith synchronous in-process dispatch and aPublishedlist for assertions.TestSessionContext/TestSessionContextProvider— preset Actor/SubjectSessionContextvalues and anISessionContextProviderdouble.InMemoryTenantMembershipStore— anITenantMembershipStoremirroring the EF store's contract semantics, including the membership-guarded active-tenant selection and the erasure sweeps.InMemorySettingStore— anISettingStorewith exact-scope reads/writes, so the scoped-settings fallback chain can be exercised without a database.TestTenants.Of("acme")— stable, deterministic tenant/user ids derived from readable slugs.TestEvent.Create(payload, ...)— wrap an event payload inIEvent<T>with realistic metadata.ProjectionTester.HandleAsync(projection, event)— invoke a projection's (private)HandleAsynchandler directly, so you can unit-test it against mocked repositories.
Example
var account = AggregateTestHarness<Account>
.Given(new AccountOpened(id, "Ada", 100m))
.And(new AmountWithdrawn(id, 30m))
.Build();
Assert.Equal(70m, account.Balance);
Dependencies
Stratara.Abstractions,Stratara.Contracts,Stratara.Shared,Stratara.SecurityMicrosoft.Extensions.DependencyInjection
Reference it from your test projects only (<PackageReference Include="Stratara.Testing" />). It is
not meant for production code paths — the InMemoryKeyStore and DummyKeyStore provide no
durability or KEK custody.
| 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
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Stratara.Abstractions (>= 3.2.1)
- Stratara.Contracts (>= 3.2.1)
- Stratara.Security (>= 3.2.1)
- Stratara.Shared (>= 3.2.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Stratara.Testing:
| Package | Downloads |
|---|---|
|
Stratara.Testing.EntityFrameworkCore
Spin up the real Stratara event-sourcing write stack (EventSource, aggregation, snapshots, the EF Core write store) against a shared in-memory SQLite database in one call — production code paths, no Postgres, no Docker. Builds on Stratara.Testing's in-memory doubles. |
GitHub repositories
This package is not used by any popular GitHub repositories.
### Fixed
- **Snapshot loads are now scoped to the aggregate type.** The snapshot read previously filtered
only by stream id, so when two aggregate types shared a stream id, rehydrating one type could
pick up the other type's (higher-versioned) snapshot and deserialize it into the requested type —
silently returning an aggregate with default/empty fields. Snapshot reads now match the aggregate
type (version-independently, so an assembly rev-bump does not invalidate existing snapshots), and
snapshot writes are grouped per `(stream, aggregate type)` so a stream carrying more than one type
snapshots each type independently. A snapshot of type X may now only ever rehydrate type X.
### Changed
- **`ISnapshotRepository` gained type-scoped read overloads.** `GetAsync(streamId,
aggregateTypeName, toVersion, ct)` and `GetLatestVersionOrDefaultAsync(streamId,
aggregateTypeName, ct)` are the correct lookups; the previous type-less overloads are now
`[Obsolete]` because they can return a foreign aggregate type's snapshot on a shared stream.
Custom `ISnapshotRepository` implementers should add the new overloads.