Documentation / Operations

Testing applications

Test a Troolio application at the contract boundaries it actually deploys. A unit test can check event decisions and replay; it cannot prove store atomicity, route admission, or crash recovery.

On this page

Useful test layers

  1. Actor logic: issue commands, inspect emitted events, replay them, and verify queries. Cover duplicate creation, stale versions, and invalid transitions.
  2. Store conformance: reject a changed batch with the same operation ID, stale expected versions, stale route epochs, and deleted owners. Prove that ancillary streams, projection handoffs, and receipt commit together.
  3. Subscriber and effect recovery: crash between claim and completion, retry a provider with the same idempotency key, and verify a definitive terminal receipt.
  4. Provider integration: use real SQL Server or KurrentDB for locking, transactions, migration, credentials, and broker failover checks.
  5. Package consumer: restore the exact public package versions into an empty-cache .NET 10 project and compile a host with the adapters it actually uses.

Adapt these layers to your own actor and provider policies. See first actor, atomic commit, and recovery.

Example: Assert the completion receipt

Tests for a selected route should inspect the durable receipt as well as resulting stream versions and projection handoffs.

public static void CheckReceipt(AtomicEventTransactionReceipt receipt)
{
    if (!receipt.AncillaryWritesCommitted || !receipt.ProjectionHandoffsCommitted)
        throw new InvalidOperationException("Commit is incomplete.");
}

Test whole application stories

Use the workshop workflow to exercise request, duplicate request, cancellation, replay, projection redelivery, and an authorized read. Verify that historical replay produces no notification or orchestration effects, that current ownership filters every query, and that a delayed add cannot resurrect a cancelled registration.