Beispiel #1
0
        public async void Withdraw_Valid_Amount()
        {
            WithdrawMessage command = new WithdrawMessage()
            {
                AccountId = Guid.NewGuid(),
                Amount    = 600
            };

            Account account = Substitute.For <Account>();

            account.Deposit(Credit.Create(Amount.Create(1000)));

            accountReadOnlyRepository
            .Get(command.AccountId)
            .Returns(account);

            Withdraw sut = new Withdraw(
                accountReadOnlyRepository,
                accountWriteOnlyRepository);

            Debit debit = await sut.Handle(command);

            Assert.Equal(command.Amount, debit.Amount.Value);
            Assert.Equal("Debit", debit.Description);
            Assert.True(debit.Id != Guid.Empty);
        }
Beispiel #2
0
        public async Task <IActionResult> Withdraw([FromBody] WithdrawMessage message)
        {
            Debit debit = await withdraw.Handle(message);

            return(Ok());
        }