Please see the code below:
public class CreatePersonHandler
: IRequestHandler<CreatePersonCommand,Unit>
{
public async Task<Unit> Handle(CreatePersonCommand message, CancellationToken cancellationToken)
{
var person = _enquiryFactory.Create(message.Gender, message.Salary);
var offers = getAvailableOffers();
person.AssignOffers(offers);
await _mediator.DispatchDomainEventsAsync(person);
return Unit.Value;
}
}
Notice that:
1) The command does not have any state.
2) The command method has no return value.
I have read a few similar questions on here e.g. this one: Unit testing void methods?. Are CQRS command handlers that return voids classed as informational and should not be unit tested?