public Response CreateAccount() { AccountRepository repo = new AccountRepository(); Account newAccount = new Account(); Response response = new Response(); newAccount.AccountNumber = 1; Console.Write("Account holder First name :"); newAccount.FirstName = Console.ReadLine(); Console.Write("Account holder Last name :"); newAccount.LastName = Console.ReadLine(); newAccount.Balance = 0.00M; int returnedAccountNumber = repo.WriteNewLine(newAccount); if (returnedAccountNumber == repo.GetAllAccounts().Count) { response.Success = true; response.CreateAccountInfo = new CreateAccountSlip(); response.CreateAccountInfo.AccountNumber = returnedAccountNumber; response.CreateAccountInfo.FirstName = newAccount.FirstName; response.CreateAccountInfo.LastName = newAccount.LastName; response.CreateAccountInfo.NewBalance = newAccount.Balance; } else { response.Success = false; response.Message = "The account was not created, please try again."; } return response; }
public void WriteNewAccount() { Account account = new Account(); account.FirstName = "Victor"; account.LastName = "Smith"; account.Balance = 1000000000000.00M; var repo = new AccountRepository(); var accounts = repo.GetAllAccounts(); var numAccounts = accounts.Count; repo.WriteNewLine(account); var accountsAfterAdd = repo.GetAllAccounts(); var numAccountsAfterAdd = accountsAfterAdd.Count; Assert.AreEqual(numAccounts +1, numAccountsAfterAdd); }