Namespace Stratara.Testing
Namespaces
Classes
- Aggregate
One-line shortcuts for rehydrating an aggregate from events in tests.
- AggregateTestHarness<TAggregate>
A given/when/then harness that rehydrates an aggregate from a sequence of events using the same reflection-based
Applydispatch as the production aggregation service — so a unit test exercises the real apply logic without an event store, database, or session context.
- InMemoryApiKeyStore
Thread-safe in-memory IApiKeyStore for tests — the drop-in double for the EF-backed key store, mirroring its contract semantics: canonical raw keys, machine keys materialized as memberships of their tenant, personal access tokens guarded by the bound user's active membership, fail-closed validation, and the idempotent import path.
- InMemoryKeyStore
In-memory IKeyStore test double. Generates a random 256-bit data-encryption key (DEK) per KeyScope on first use, hands the embedded key id back on lookup, and supports rotation, revocation, scope erasure and marking a subject erased with the same observable semantics as the production
EnvelopeFileKeyStore— but without KEK wrapping, on-disk files, or a IMasterKeyProvider.
- InMemoryMessageBus
In-memory IMessageBus test double with synchronous, in-process dispatch: a PublishAsync<T>(string, T, CancellationToken) call immediately awaits every handler subscribed to the topic whose message type is compatible, so tests observe handler effects without a broker.
- InMemorySettingStore
Thread-safe in-memory ISettingStore for tests — the drop-in double for the EF-backed setting store, mirroring its contract semantics: exact-scope reads/writes,
null-value deletion, and the widened erasure-sweep semantics of DeleteScopeAsync(SettingScope, CancellationToken) (a user scope erases the user's values across all tenants, a tenant scope erases the tenant's values across all users, the global scope erases only global values).
- InMemoryTenantMembershipStore
Thread-safe in-memory ITenantMembershipStore for tests — the drop-in double for the EF-backed membership store, mirroring its contract semantics: upsert on SetMembershipAsync(TenantMembership, CancellationToken), erasure sweeps per user and per tenant, and the membership-guarded active-tenant selection (selecting a tenant without an active membership throws, removals clear a now-dangling selection).
- ProjectionTester
Invokes a projection's event handler directly in a test. Stratara projections declare their
HandleAsyncmethods as private (the runtime discovers them by reflection), so a unit test cannot call them without this helper. Pair it with mocked repositories / unit-of-work to assert what the projection wrote.
- PublishedMessage
A message captured by InMemoryMessageBus for test assertions.
- TestBlobEncryptor
Factory for the framework's real AES-GCM ISecureBlobEncryptor backed by an InMemoryKeyStore, so blob round-trips in tests exercise the production encryptor (scope- and purpose-bound associated data, v2 stream format) without a master KEK or an on-disk key file.
- TestEvent
Builds IEvent<TEvent> wrappers around event payloads for tests, so projection and saga handlers that take
IEvent<TData>can be fed an event with realistic metadata (id, version, stream id, tenant) without going through the event store.
- TestSessionContext
Builds ready-made SessionContext values for tests, with fresh correlation + causation ids (so the context can drive event-store writes) and the Actor (who triggered) defaulted to the Subject (data owner) unless overridden.
- TestSessionContextProvider
An ISessionContextProvider test double whose Current is set directly, so code under test that reads the ambient session (repositories, encryption AAD, tenant guards) runs without HTTP middleware or a worker dispatch loop.
- TestTenants
Maps human-readable slugs to stable, deterministic Guid tenant ids, so test assertions stay readable (
TestTenants.Of("acme")) while the system still round-trips real GUID identities. The same slug always yields the same id within and across test runs.