Class CommandExtensions
Inheritance
System.Object
CommandExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public static class CommandExtensions
Methods
ExecuteAsync(ICommand, CancellationToken)
executes the command that does not return a result
Declaration
public static Task ExecuteAsync(this ICommand command, CancellationToken ct = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
ICommand | command | the command to execute |
System.Threading.CancellationToken | ct | optional cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | thrown when a handler for the command cannot be instantiated |
ExecuteAsync<TResult>(ICommand<TResult>, CancellationToken)
executes the command and returns a result
Declaration
public static Task<TResult> ExecuteAsync<TResult>(this ICommand<TResult> command, CancellationToken ct = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
ICommand<TResult> | command | the command to execute |
System.Threading.CancellationToken | ct | optional cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult> |
Type Parameters
Name | Description |
---|---|
TResult | the type of the returned result |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | thrown when a handler for the command cannot be instantiated |
RegisterForTesting<TCommand>(ICommandHandler<TCommand>)
registers a fake command handler for unit testing purposes
Declaration
public static void RegisterForTesting<TCommand>(this ICommandHandler<TCommand> handler)
where TCommand : ICommand
Parameters
Type | Name | Description |
---|---|---|
ICommandHandler<TCommand> | handler | a fake handler instance |
Type Parameters
Name | Description |
---|---|
TCommand | type of the command |
RegisterForTesting<TCommand, TResult>(ICommandHandler<TCommand, TResult>)
registers a fake command handler for unit testing purposes
Declaration
public static void RegisterForTesting<TCommand, TResult>(this ICommandHandler<TCommand, TResult> handler)
where TCommand : ICommand<TResult>
Parameters
Type | Name | Description |
---|---|---|
ICommandHandler<TCommand, TResult> | handler | a fake handler instance |
Type Parameters
Name | Description |
---|---|
TCommand | type of the command |
TResult | type of the result being returned by the handler |