Exemple #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);
        }
Exemple #2
0
        public async Task ClosedAccount_ValidAccount_ShouldCompleteTask()
        {
            //ARRANGE
            var customerId = Guid.NewGuid();
            var account    = new Account(customerId);

            _accountReadOnlyRepository.Setup(m => m.Get(account.Id)).Returns(Task.FromResult(account));
            _accountWriteOnlyRepository.Setup(m => m.Delete(account)).Returns(Task.CompletedTask);

            //ACT
            Guid accountId = await closedAccountUseCase.Execute(account.Id);

            //ASSERT
            _accountReadOnlyRepository.Verify(v => v.Get(account.Id), Times.Once());
            _accountWriteOnlyRepository.Verify(v => v.Delete(account), Times.Once());
            Assert.Equal(account.Id, accountId);
            Assert.NotEqual(customerId, accountId);
        }