Skip to main content
Table of Contents

Class ProjectionTester

Namespace
Stratara.Testing
Assembly
Stratara.Testing.dll

Invokes a projection's event handler directly in a test. Stratara projections declare their HandleAsync methods 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.

public static class ProjectionTester
Inheritance
ProjectionTester
Inherited Members

Methods

HandleAsync<TData>(object, IEvent<TData>, CancellationToken)

Dispatch event to projection's handler — trying HandleAsync(IEvent<TData>, CancellationToken) first, then HandleAsync(TData, CancellationToken).

public static Task HandleAsync<TData>(object projection, IEvent<TData> @event, CancellationToken cancellationToken = default) where TData : notnull

Parameters

projection object

The projection instance (its handler may be public or private).

event IEvent<TData>

The event to dispatch — build one with Create<TData>(TData, Guid?, long, Guid?, Guid?).

cancellationToken CancellationToken

Propagated to the handler.

Returns

Task

The task returned by the projection handler.

Type Parameters

TData

The event payload type.

Exceptions

InvalidOperationException

The projection has no matching HandleAsync overload.