コード例 #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 async Task GetAccountDetails_ValidId_ShouldReturnAnAccount()
        {
            //ARRANGE
            var     accountId = Guid.NewGuid();
            Account account   = BuildAccount(accountId);

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

            //ACT
            AccountOutput outPut = await getAccountDetailsUseCase.Execute(account.Id);

            //ASSERT
            _accountReadOnlyRepository.Verify(v => v.Get(account.Id), Times.Once());
            Assert.Equal(account.Id, outPut.AccountId);
            Assert.NotEmpty(outPut.Transactions);
        }