public void TestGetAllTransactionsForAccount() { int expected = 1; IBankService bankService = ServiceProvider.GetService <IBankService>(); Account account = CreateTestAccount("username", "password"); bankService.CreateAccount(account); Account account2 = CreateTestAccount("usernameone", "passwordtwo"); Transactions transactionsOne = CreateTestDepositTransaction(account, 100); Transactions transactionsTwo = CreateTestDepositTransaction(account2, 100); bankService.CreateTransaction(transactionsOne); bankService.CreateTransaction(transactionsTwo); List <Transactions> transactionList = bankService.GetAllTransactionsForAccount(account.AccountId).ToList(); Assert.Equal(expected, transactionList.Count); }
public IHttpActionResult ExecuteTransaction(Int64 accountId, TransactionType type, Decimal amount) { var account = _bankService.GetAccountById(accountId); if (account == null) { return(NotFound()); } var transaction = _bankService.CreateTransaction(type, account, amount); _uow.Commit(); _bankService.ExecuteTransaction(transaction); _uow.Commit(); var vm = new { Balance = account.Balance, Transaction = new TransactionViewModel(transaction) }; return(OkResult(vm)); }