Class ProjectionTester
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
projectionobjectThe projection instance (its handler may be public or private).
eventIEvent<TData>The event to dispatch — build one with Create<TData>(TData, Guid?, long, Guid?, Guid?).
cancellationTokenCancellationTokenPropagated to the handler.
Returns
- Task
The task returned by the projection handler.
Type Parameters
TDataThe event payload type.
Exceptions
- InvalidOperationException
The projection has no matching
HandleAsyncoverload.