Class TestingExtensions
extension methods for registering fake/test/mock command and event handlers for integration testing
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public static class TestingExtensions
Methods
GetTestEventReceiver<TEvent>(IServiceProvider)
gets a test event receiver for a given event type.
Declaration
public static IEventReceiver<TEvent> GetTestEventReceiver<TEvent>(this IServiceProvider provider) where TEvent : IEvent
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider |
Returns
| Type | Description |
|---|---|
| IEventReceiver<TEvent> |
Type Parameters
| Name | Description |
|---|---|
| TEvent | the type of the event |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | thrown when test event receivers are not registered |
RegisterTestCommandHandler<TCommand, THandler>(IServiceCollection)
register test/fake/mock command handlers for integration testing commands that don't return a result
Declaration
public static void RegisterTestCommandHandler<TCommand, THandler>(this IServiceCollection s) where TCommand : ICommand where THandler : class, ICommandHandler<TCommand>
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | s |
Type Parameters
| Name | Description |
|---|---|
| TCommand | the type of the command model to register a test handler for |
| THandler | the type of the test command handler |
RegisterTestCommandHandler<TCommand, THandler, TResult>(IServiceCollection)
register test/fake/mock command handlers for integration testing commands that returns a result
Declaration
public static void RegisterTestCommandHandler<TCommand, THandler, TResult>(this IServiceCollection s) where TCommand : ICommand<TResult> where THandler : class, ICommandHandler<TCommand, TResult>
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | s |
Type Parameters
| Name | Description |
|---|---|
| TCommand | the type of the command model to register a test handler for |
| THandler | the type of the test command handler |
| TResult | the type of the result |
RegisterTestEventHandler<TEvent, THandler>(IServiceCollection)
register test/fake/mock event handlers for integration testing events
Declaration
public static void RegisterTestEventHandler<TEvent, THandler>(this IServiceCollection s) where TEvent : IEvent where THandler : class, IEventHandler<TEvent>
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | s |
Type Parameters
| Name | Description |
|---|---|
| TEvent | the type of the event model to register a test handler for |
| THandler | the type of the test event handler |
RegisterTestEventReceivers(IServiceCollection)
registers test event receivers for the purpose of testing receipt of events.
Declaration
public static IServiceCollection RegisterTestEventReceivers(this IServiceCollection s)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | s |
Returns
| Type | Description |
|---|---|
| IServiceCollection |