public async Task Run() { var newCommand = new DraftExpireFundsCommand { DateTo = new DateTime(2018, 5, 1) }; await _messageSession.Send(newCommand); }
public async Task Then_Creates_Draft_Command_For_Each_Account( DraftExpireFundsCommand command, DateTime expectedDate, DateTime expectedRunDate, Models.Account.Account accountOne, Models.Account.Account accountTwo, [Frozen] Mock <ICurrentDateTime> currentDateTime, [Frozen] Mock <IEmployerAccountRepository> repository, Mock <IMessageHandlerContext> context, DraftExpireFundsCommandHandler handler ) { currentDateTime.Setup(x => x.Now).Returns(expectedRunDate); command.DateTo = expectedDate; var accounts = new List <Models.Account.Account> { accountOne, accountTwo }; repository.Setup(x => x.GetAllAccounts()).ReturnsAsync(accounts); await handler.Handle(command, context.Object); context.Verify(x => x.Send( It.Is <DraftExpireAccountFundsCommand>(c => c.AccountId.Equals(accountOne.Id) && c.DateTo.Equals(command.DateTo)), It.Is <SendOptions>(o => o.RequiredImmediateDispatch() && o.IsRoutingToThisEndpoint())), Times.Once()); context.Verify(x => x.Send( It.Is <DraftExpireAccountFundsCommand>(c => c.AccountId.Equals(accountTwo.Id) && c.DateTo.Equals(command.DateTo)), It.Is <SendOptions>(o => o.RequiredImmediateDispatch() && o.IsRoutingToThisEndpoint())), Times.Once()); }