public void PerformTransferErrorNegativeTransference() { TransferDomainService transferDomainService = new TransferDomainService(); Account originAccount = GetOriginAccount(); Account destinationAccount = GetDestinationAccount(); decimal amount = -50; Action action = () => transferDomainService.PerformTransfer(originAccount, destinationAccount, amount); Assert.Throws <ArgumentException>(action); }
public void PerformTransferErrorInvalidAccounts() { TransferDomainService transferDomainService = new TransferDomainService(); Account originAccount = null; Account destinationAccount = null; decimal amount = 35; Action action = () => transferDomainService.PerformTransfer(originAccount, destinationAccount, amount); Assert.Throws <ArgumentException>(action); }
public void PerformTransferSuccess() { TransferDomainService transferDomainService = new TransferDomainService(); Account originAccount = GetOriginAccount(); Account destinationAccount = GetDestinationAccount(); decimal amount = 35; transferDomainService.PerformTransfer(originAccount, destinationAccount, amount); Assert.Equal(65, originAccount.Balance); Assert.Equal(45, destinationAccount.Balance); }
public void PerformTransfer(BankAccountDto originBankAccountDto, BankAccountDto destinationBankAccountDto, decimal amount) { var scope = new TransactionScope(); using (scope) { var originAccount = _bankAccountRepository.FindByNumber(originBankAccountDto.Number); var destinationAccount = _bankAccountRepository.FindByNumber(destinationBankAccountDto.Number); _transferDomainService.PerformTransfer(originAccount, destinationAccount, amount); _bankAccountRepository.update(originAccount); _bankAccountRepository.update(destinationAccount); scope.Complete(); } }
public void TestPerformTransfer() { TransferDomainService transferDomainService = new TransferDomainService(); Assert.Throws <ArgumentException>(() => transferDomainService.PerformTransfer(null, null, 0)); }