public void AccountWithdrawFails()
        {
            var repo = new AccountRepository();
            var accountToWithdraw = repo.LoadAccount(2);
            var accountManager = new AccountManager();
            var response = accountManager.Withdraw(accountToWithdraw, 200M);

            Assert.AreEqual(false, response.Success);
        }
        public void CanLoadAccount()
        {
            var repo = new AccountRepository();

            var account = repo.LoadAccount(1);

            Assert.AreEqual(1, account.AccountNumber);
            Assert.AreEqual("Mary", account.FirstName);
        }
        public void AccountDepositFailsZero()
        {
            var repo = new AccountRepository();
            var accountToDeposit = repo.LoadAccount(2);
            var accountManager = new AccountManager();
            var response = accountManager.Deposit(accountToDeposit, 0);

            Assert.IsFalse(response.Success);
        }
        public void AccountWithdrawSucceeds()
        {
            var repo = new AccountRepository();
            var accountToWithdraw = repo.LoadAccount(3);
            var accountManager = new AccountManager();
            var response = accountManager.Withdraw(accountToWithdraw, 100M);

            Assert.AreEqual(455M, response.Data.NewBalance);
            Assert.AreEqual(100M, response.Data.WithdrawAmount);
            Assert.AreEqual(true, response.Success);
        }
        public void AccountDepositSucceeds()
        {
            var repo = new AccountRepository();
            var accountToDeposit = repo.LoadAccount(1);
            var accountManager = new AccountManager();
            var response = accountManager.Deposit(accountToDeposit, 150M);

            Assert.AreEqual(497M, response.Data.NewBalance);
            Assert.AreEqual(150M, response.Data.DepositAmount);
            Assert.AreEqual(true, response.Success);
        }
示例#6
0
        public Response<Account> GetAccount(int accountNumber)
        {
            var repo = new AccountRepository();
            var response = new Response<Account>();

            try
            {
                var account = repo.LoadAccount(accountNumber);

                if (account == null)
                {
                    response.Success = false;
                    response.Message = "Account was not found!";
                }
                else
                {
                    response.Success = true;
                    response.Data = account;
                }
            }
            catch (Exception ex)
            {
                // log the exception
                response.Success = false;
                response.Message = "There was an error.  Please try again later.";
            }

            return response;
        }
        public void CheckAddAccount()
        {
            var repo = new AccountRepository();
            var newAccount = new Account()
            {
                FirstName = "Homer",
                LastName = "Simpson",
                Balance = 500
            };

            repo.AddAccount(newAccount);
            repo.GetAllAccounts();
            var result = repo.LoadAccount(repo.HighestAccountNumber());

            Assert.AreEqual(result.Balance, newAccount.Balance);
            Assert.AreEqual(result.LastName, newAccount.LastName);
            Assert.AreEqual(result.FirstName, newAccount.FirstName);
            Assert.AreEqual(result.AccountNumber, 5);
        }
        public void UpdateAccountSucceeds()
        {
            var repo = new AccountRepository();
            var accountToUpdate = repo.LoadAccount(1);
            accountToUpdate.Balance = 500.00M;
            repo.UpdateAccount(accountToUpdate);

            var result = repo.LoadAccount(1);

            Assert.AreEqual(500.00M, result.Balance);
        }
        public void DeleteSuccess()
        {
            var repo = new AccountRepository();

            repo.RemoveAccount(3);

            var account = repo.LoadAccount(3);

            Assert.IsNull(account);
        }