Exemplo n.º 1
0
            public async Task WhenAllConditionsAreMet_ShouldPerformWithdrawal()
            {
                Given.ValidAccountExistsInDatabase(FromAccount);
                And.UserIsAuthorisedToWithdraw(FromAccount, User);
                And.AccountHasEnoughFundsForWithdrawal(FromAccount, WithdrawalAmount);

                await When.Withdraw(WithdrawalAmount, FromAccount, User);

                await Then.DidWithdrawalForAccount(FromAccount, WithdrawalAmount);
            }
Exemplo n.º 2
0
            public async Task AfterSuccessfulWithdrawal_ShouldCommitDatabaseTransaction()
            {
                Given.ValidAccountExistsInDatabase(FromAccount);
                And.ValidAccountExistsInDatabase(ToAccount);
                And.UserIsAuthorisedToWithdraw(FromAccount, User);
                And.AccountHasEnoughFundsForWithdrawal(FromAccount, WithdrawalAmount);

                await When.TransferMoney(WithdrawalAmount, FromAccount, ToAccount, User);

                await Then.TransactionWasCommited();
            }
Exemplo n.º 3
0
            public async Task WhenAllConditionsAreMet_ShouldPerformDeposit()
            {
                Given.ValidAccountExistsInDatabase(FromAccount);
                And.ValidAccountExistsInDatabase(ToAccount);
                And.UserIsAuthorisedToWithdraw(FromAccount, User);
                And.AccountHasEnoughFundsForWithdrawal(FromAccount, WithdrawalAmount);

                await When.TransferMoney(WithdrawalAmount, FromAccount, ToAccount, User);

                await Then.DidDepositToAccount(ToAccount, WithdrawalAmount);
            }
Exemplo n.º 4
0
            public async Task SuccessfulWithdrawal_ShouldReturnTrue()
            {
                Given.ValidAccountExistsInDatabase(FromAccount);
                And.UserIsAuthorisedToWithdraw(FromAccount, User);
                And.AccountHasEnoughFundsForWithdrawal(FromAccount, WithdrawalAmount);

                // When
                var transactionResult = await SUT.Withdraw(WithdrawalAmount, FromAccount, User);

                // Then
                transactionResult.Should().BeTrue();
            }
Exemplo n.º 5
0
            public async Task AfterSuccessfulWithdrawal_ShouldCommitDatabaseTransaction()
            {
                Given.ValidAccountExistsInDatabase(FromAccount);
                And.UserIsAuthorisedToWithdraw(FromAccount, User);
                And.AccountHasEnoughFundsForWithdrawal(FromAccount, WithdrawalAmount);

                await When.Withdraw(WithdrawalAmount, FromAccount, User);

                await Then.TransactionWasCommited();

                // or
                // await Mock<IAccountRepository>().Received().CommitTransaction(Arg.Any<int>());
            }