Пример #1
0
        public async Task NewAccount_Should_Allows_Closing2()
        {
            var getAccountPresenter   = new GetAccountDetailsPresenter();
            var closeAccountPresenter = new CloseAccountPresenter();
            var withdrawPresenter     = new WithdrawPresenter();

            var getAccountUseCase = new GetAccountDetailsUseCase(
                getAccountPresenter, this._fixture.AccountRepository);

            var withdrawUseCase = new WithdrawUseCase(this._fixture.AccountService,
                                                      withdrawPresenter, this._fixture.AccountRepository, this._fixture.UnitOfWork);

            var sut = new CloseAccountUseCase(
                closeAccountPresenter, this._fixture.AccountRepository);

            await getAccountUseCase.Execute(new GetAccountDetailsInput(this._fixture.Context.DefaultAccountId));

            var getAccountDetailtOutput = getAccountPresenter.GetAccountDetails.First();

            await withdrawUseCase.Execute(new WithdrawInput(this._fixture.Context.DefaultAccountId,
                                                            new PositiveMoney(getAccountDetailtOutput.CurrentBalance.ToDecimal())));

            var input = new CloseAccountInput(this._fixture.Context.DefaultAccountId);
            await sut.Execute(input);

            Assert.Equal(input.AccountId, closeAccountPresenter.ClosedAccounts.First().AccountId);
        }
Пример #2
0
        public WithdrawUseCaseTest()
        {
            _accountReadOnlyRepository  = new Mock <IAccountReadOnlyRepository>();
            _accountWriteOnlyRepository = new Mock <IAccountWriteOnlyRepository>();

            withdrawUseCase = new WithdrawUseCase(_accountReadOnlyRepository.Object, _accountWriteOnlyRepository.Object);
        }
        public WhenWithdrawingMoney()
        {
            _bankAccountStoreMock     = new Mock <IBankAccountStore>();
            _accountAuthorisationMock = new Mock <IAccountAuthorisation>();
            _useCase = new WithdrawUseCase(_bankAccountStoreMock.Object, _accountAuthorisationMock.Object);

            GivenAuthorisationRequesSucceeds();
        }
        public async Task Withdraw_Valid_Amount(
            decimal amount,
            decimal expectedBalance)
        {
            var presenter = new WithdrawPresenter();
            var sut       = new WithdrawUseCase(this._fixture.AccountService,
                                                presenter, this._fixture.AccountRepository, this._fixture.UnitOfWork);

            await sut.Execute(new WithdrawInput(this._fixture.Context.DefaultAccountId,
                                                new PositiveMoney(amount)));

            var actual = presenter.Withdrawals.Last();

            Assert.Equal(expectedBalance, actual.UpdatedBalance.ToDecimal());
        }
Пример #5
0
        public async void Withdraw_Valid_Amount(string accountId, decimal amount)
        {
            var mockAccountReadOnlyRepository  = new Mock <IAccountReadOnlyRepository>();
            var mockAccountWriteOnlyRepository = new Mock <IAccountWriteOnlyRepository>();
            TransactionCollection transactions = new TransactionCollection();

            transactions.Add(new Credit(Guid.Empty, 4000));

            Account account = Account.LoadFromDetails(Guid.Parse(accountId), Guid.Empty, transactions);

            mockAccountReadOnlyRepository.SetupSequence(e => e.Get(It.IsAny <Guid>()))
            .ReturnsAsync(account);

            WithdrawUseCase sut = new WithdrawUseCase(
                mockAccountReadOnlyRepository.Object,
                mockAccountWriteOnlyRepository.Object
                );

            WithdrawOutput output = await sut.Execute(
                Guid.Parse(accountId),
                amount);

            Assert.Equal(3900, output.UpdatedBalance);
        }
Пример #6
0
 public WithdrawCommand(WithdrawUseCase useCase)
 {
     _useCase = useCase;
 }