public DepositUseCaseTest() { _accountReadOnlyRepository = new Mock <IAccountReadOnlyRepository>(); _accountWriteOnlyRepository = new Mock <IAccountWriteOnlyRepository>(); depositUseCase = new DepositUseCase(_accountReadOnlyRepository.Object, _accountWriteOnlyRepository.Object); }
public WhenDepositingMoney() { _bankAccountStoreMock = new Mock <IBankAccountStore>(); _accountAuthorisationMock = new Mock <IAccountAuthorisation>(); _useCase = new DepositUseCase(_bankAccountStoreMock.Object, _accountAuthorisationMock.Object); GivenAuthorisationRequesSucceeds(); }
public async Task Deposit_ShouldNot_ChangesBalance_WhenNegative(decimal amount) { var presenter = new DepositPresenter(); var sut = new DepositUseCase(this._fixture.AccountService, presenter, this._fixture.AccountRepository, this._fixture.UnitOfWork); await Assert.ThrowsAsync <MoneyShouldBePositiveException>(() => sut.Execute( new DepositInput(this._fixture.Context.DefaultAccountId, new PositiveMoney(amount)))); }
public async Task Deposit_ChangesBalance(decimal amount) { var presenter = new DepositPresenter(); var sut = new DepositUseCase(this._fixture.AccountService, presenter, this._fixture.AccountRepository, this._fixture.UnitOfWork); await sut.Execute( new DepositInput(this._fixture.Context.DefaultAccountId, new PositiveMoney(amount))); var output = presenter.Deposits.Last(); Assert.Equal(amount, output.Transaction.Amount.ToMoney().ToDecimal()); }
public async void Deposit_Valid_Amount(string accountId, double amount) { var account = new Account(Guid.NewGuid()); var customer = new Customer("08724050601", "Jorge Perales Diaz"); accountReadOnlyRepository .Get(Guid.Parse(accountId)) .Returns(account); var depositUseCase = new DepositUseCase( accountReadOnlyRepository, accountWriteOnlyRepository ); DepositResult result = await depositUseCase.Execute( Guid.Parse(accountId), amount); Assert.Equal(amount, result.Transaction.Amount); }
public async void Deposit_Valid_Amount(string accountId, decimal amount) { var mockAccountReadOnlyRepository = new Mock <IAccountReadOnlyRepository>(); var mockAccountWriteOnlyRepository = new Mock <IAccountWriteOnlyRepository>(); Account account = new Account(Guid.Parse(accountId)); mockAccountReadOnlyRepository.SetupSequence(e => e.Get(It.IsAny <Guid>())) .ReturnsAsync(account); DepositUseCase sut = new DepositUseCase( mockAccountReadOnlyRepository.Object, mockAccountWriteOnlyRepository.Object ); DepositOutput output = await sut.Execute( Guid.Parse(accountId), amount); Assert.Equal(100, output.UpdatedBalance); }
public DepositCommand(DepositUseCase useCase) { _useCase = useCase; }