public void TestMakeTransfer_debit() { var operationsList = new List<Operation>(); SIOperationRepository opRepository = new SIOperationRepository(); opRepository.CreateOperationOperation = (x) => { operationsList.Add(x); }; SIAccountRepository acRepository = new SIAccountRepository(); acRepository.UpdateAccountAccount = (x) => { var acc1 = _accounts.SingleOrDefault(y => y.Id == x.Id); acc1.Operations = x.Operations; }; AccountService service = new AccountService(acRepository, opRepository); service.MakeTransfer(_accounts[1], _accounts[0], 200); Assert.AreEqual(_accounts[1].Balance, 200); Assert.AreEqual(_accounts[0].Balance, 100); Assert.AreEqual(operationsList.Count, 2); Assert.AreEqual(_accounts[1].Operations.Count, 2); Assert.AreEqual(_accounts[0].Operations.Count, 3); }
public List <Operation> GetOperationsForAccount(int accountID) { List <Operation> operations1 = new List <Operation>(); operations1.Add(new Operation { Amount = 100, Direction = Domain.Direction.Credit }); operations1.Add(new Operation { Amount = 200, Direction = Domain.Direction.Debit }); List <Account> accounts = new List <Account>(); accounts.Add(new Account { Balance = 300, Operations = operations1, AutorizeOverdraft = true, Id = 1 }); accounts.Add(new Account { Balance = 0, Operations = null, AutorizeOverdraft = false, Id = 2 }); SIAccountRepository accountRepository = new SIAccountRepository(); accountRepository.GetAccountInt32 = (x) => { return(accounts.SingleOrDefault(a => a.Id == x)); }; SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); List <Operation> result = service.GetOperationsForAccount(accountID); return(result); }
public void TestMakeTransfer_debit() { var operationsList = new List <Operation>(); SIOperationRepository opRepository = new SIOperationRepository(); opRepository.CreateOperationOperation = (x) => { operationsList.Add(x); }; SIAccountRepository acRepository = new SIAccountRepository(); acRepository.UpdateAccountAccount = (x) => { var acc1 = _accounts.SingleOrDefault(y => y.Id == x.Id); acc1.Operations = x.Operations; }; AccountService service = new AccountService(acRepository, opRepository); service.MakeTransfer(_accounts[1], _accounts[0], 200); Assert.AreEqual(_accounts[1].Balance, 200); Assert.AreEqual(_accounts[0].Balance, 100); Assert.AreEqual(operationsList.Count, 2); Assert.AreEqual(_accounts[1].Operations.Count, 2); Assert.AreEqual(_accounts[0].Operations.Count, 3); }
public void MakeTransfer(Account creditAccount,Account debitAccount,decimal amount) { SIAccountRepository accountRepository = new SIAccountRepository(); SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); service.MakeTransfer(creditAccount, debitAccount, amount); }
public void MakeTransfer(Account creditAccount, Account debitAccount, decimal amount) { SIAccountRepository accountRepository = new SIAccountRepository(); SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); service.MakeTransfer(creditAccount, debitAccount, amount); }
public decimal Balance(Account account) { SIRepository repository = new SIRepository(); SIAccountRepository accountRepository = new SIAccountRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); IDtoCreator<Account, AccountDto> accountCreator = new AccountDtoCreator(); //act var accountServices = new AccountServices(repository, accountRepository, customerRepository, accountCreator); var result = accountServices.Balance(account); return result; }
public decimal Balance(Account account) { SIRepository repository = new SIRepository(); SIAccountRepository accountRepository = new SIAccountRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); IDtoCreator <Account, AccountDto> accountCreator = new AccountDtoCreator(); //act var accountServices = new AccountServices(repository, accountRepository, customerRepository, accountCreator); var result = accountServices.Balance(account); return(result); }
public void GetOperationsForAccount_AccountFound() { SIAccountRepository accountRepository = new SIAccountRepository(); accountRepository.GetAccountInt32 = (x) => { return _accounts.SingleOrDefault(a => a.Id == x); }; SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); List<Operation> result = service.GetOperationsForAccount(1); Assert.AreEqual(result.Count, 2); }
public decimal ComputeInterest(Account account, double annualRate, int months) { PexAssume.Implies(account != null, () => account.Balance = 1000); PexAssume.IsTrue(annualRate != 0); PexAssume.IsTrue(months != 0); SIAccountRepository accountRepository = new SIAccountRepository(); SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); decimal result = service.ComputeInterest(account, annualRate, months); return(result); }
public decimal ComputeInterest(Account account,double annualRate,int months) { PexAssume.Implies(account != null, () => account.Balance = 1000); PexAssume.IsTrue(annualRate != 0); PexAssume.IsTrue(months != 0); SIAccountRepository accountRepository = new SIAccountRepository(); SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); decimal result = service.ComputeInterest(account, annualRate, months); return result; }
public void GetOperationsForAccount_AccountFound() { SIAccountRepository accountRepository = new SIAccountRepository(); accountRepository.GetAccountInt32 = (x) => { return(_accounts.SingleOrDefault(a => a.Id == x)); }; SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); List <Operation> result = service.GetOperationsForAccount(1); Assert.AreEqual(result.Count, 2); }
public List<Operation> GetOperationsForAccount(int accountID) { List<Operation> operations1 = new List<Operation>(); operations1.Add(new Operation { Amount = 100, Direction = Domain.Direction.Credit }); operations1.Add(new Operation { Amount = 200, Direction = Domain.Direction.Debit }); List<Account> accounts = new List<Account>(); accounts.Add(new Account { Balance = 300, Operations = operations1, AutorizeOverdraft = true, Id = 1 }); accounts.Add(new Account { Balance = 0, Operations = null, AutorizeOverdraft = false, Id = 2 }); SIAccountRepository accountRepository = new SIAccountRepository(); accountRepository.GetAccountInt32 = (x) => { return accounts.SingleOrDefault(a => a.Id == x); }; SIOperationRepository operationRepository = new SIOperationRepository(); AccountService service = new AccountService(accountRepository, operationRepository); List<Operation> result = service.GetOperationsForAccount(accountID); return result; }