public async Task wire_transfert_command_should_throw_excpetion_if_amount_negative_or0(decimal amount) { var accountId = Guid.Parse("1805FB93-2A90-4C9C-B286-EE9A62A94212"); Account account = GetAccount(); var repo = new Mock <Myrepo.IRepository>(); repo.Setup(x => x.GetById <Account>(It.IsAny <Guid>())).Returns(Task.FromResult(account)); CommandHandler commandHandler = new CommandHandler(repo.Object); WireTransferCommand wireTransfer = new WireTransferCommand(accountId, amount); await Assert.ThrowsAsync <InvalidOperationException>(() => commandHandler.Handle(wireTransfer)); }
public async Task wire_transfer_limit_command_should_update_debt_amount() { #region Arrange var accountId = Guid.Parse("1805FB93-2A90-4C9C-B286-EE9A62A94212"); Account account = GetAccount(); var repo = new Mock <Myrepo.IRepository>(); repo.Setup(x => x.GetById <Account>(It.IsAny <Guid>())).Returns(Task.FromResult(account)); CommandHandler commandHandler = new CommandHandler(repo.Object); SetDailyWireTransferLimitCommand setDailyWireTransferLimit = new SetDailyWireTransferLimitCommand(accountId, 1500); WireTransferCommand wireTransfer = new WireTransferCommand(accountId, 100); #endregion await commandHandler.Handle(new DepositeCashCommand(accountId, 200)); await commandHandler.Handle(setDailyWireTransferLimit); await commandHandler.Handle(wireTransfer); Assert.Equal(100, account.Debt); }
public async Task Handle(WireTransferCommand cmd) { await Execute(cmd.AccountId, (account) => account.WireTransfert(cmd.Amount)); }