Esempio n. 1
0
        public async Task NewAccount_Should_Allows_Closing2()
        {
            var getAccountPresenter   = new GetAccountDetailsPresenter();
            var closeAccountPresenter = new CloseAccountPresenter();
            var withdrawPresenter     = new WithdrawPresenter();

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

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

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

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

            var getAccountDetailtOutput = getAccountPresenter.GetAccountDetails.First();

            await withdrawUseCase.Execute(new Application.Boundaries.Withdraw.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);
        }
Esempio n. 2
0
        public async Task <IActionResult> GetAccountDetails(
            [FromServices] IMediator mediator,
            [FromServices] GetAccountDetailsPresenter presenter)
        {
            var accountId = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "AccountId").Value;
            var input     = new GetAccountDetailsInput(new BaseEntityId(new Guid(accountId)));
            await mediator.PublishAsync(input);

            return(presenter.ViewModel);
        }