Beispiel #1
0
        public void CanWithdrawFromAccountInFile(string accountNumber, decimal depositAmount, bool expectedResult)
        {
            IAccountRepository      repo           = new FileAccountRepository();
            Account                 account        = repo.LoadAccount(accountNumber);
            AccountManager          accountManager = new AccountManager(repo);
            AccountWithdrawResponse response       = accountManager.Withdraw(account.AccountNumber, depositAmount);

            Assert.AreEqual(expectedResult, response.Success);
        }
Beispiel #2
0
        public void PositiveOrZeroAmountWithdrawalsFail(string accountNumber, decimal amount)
        {
            IAccountRepository      repo           = new FileAccountRepository();
            Account                 account        = repo.LoadAccount(accountNumber);
            AccountManager          accountManager = new AccountManager(repo);
            AccountWithdrawResponse response       = accountManager.Withdraw(account.AccountNumber, amount);

            Assert.IsFalse(response.Success);
        }
Beispiel #3
0
        public void CanReadDataFromFile()
        {
            FileAccountRepository repo = new FileAccountRepository(_testpath);
            Account account            = repo.LoadAccount("33333");

            Assert.AreEqual("33333", account.AccountNumber);
            Assert.AreEqual("Premium Customer", account.Name);
            Assert.AreEqual(1000, account.Balance);
            Assert.AreEqual(AccountType.Premium, account.Type);
        }
Beispiel #4
0
        public void CanLoadAccountFromFile()
        {
            IAccountRepository repo    = new FileAccountRepository();
            Account            account = repo.LoadAccount("1");

            Assert.AreEqual("1", account.AccountNumber);
            Assert.AreEqual("Michael Jackson", account.Name);
            Assert.AreEqual(150.00M, account.Balance);
            Assert.AreEqual(AccountType.Basic, account.Type);
        }
Beispiel #5
0
        public static void CanLoadAccountTestDataFromFile(string accountNumber)
        {
            FileAccountRepository TestFileRepo =
                new FileAccountRepository("C:/Users/Jeremy/source/repos/SGBank052020/SGBank.Data/AccountsForTestingLoad.txt");
            Account a = TestFileRepo.LoadAccount(accountNumber);


            Assert.AreEqual(a.AccountNumber, accountNumber);
            Assert.IsNotNull(TestFileRepo._account);
        }
        public void CanLoadFileAccountTestData(string AccountNumber)
        {
            FileAccountRepository repo     = new FileAccountRepository(_FilePath);
            List <Account>        accounts = repo.List();

            AccountNumber = "22222";
            Account account = repo.LoadAccount(AccountNumber);


            Assert.AreEqual("22222", account.AccountNumber);
        }
Beispiel #7
0
        public void CanReadDataFromFile()
        {
            FileAccountRepository test = new FileAccountRepository(_path);

            var checkData = test.LoadAccount("11111");

            Assert.AreEqual(checkData.AccountNumber, "11111");
            Assert.AreEqual(checkData.Name, "Free Customer");
            Assert.AreEqual(checkData.Balance, 100);
            Assert.AreEqual(checkData.Type, AccountType.Free);
        }
Beispiel #8
0
        public static void CorrectAmountDepositAndWithdrawFree(string accountNumber)
        {
            //after this files are in arraylist
            FileAccountRepository TestFileRepo =
                new FileAccountRepository("C:/Users/Jeremy/source/repos/SGBank052020/SGBank.Data/AccountsForTestingDeposit.txt");
            Account  a = TestFileRepo.LoadAccount(accountNumber);
            decimal  beginningBalance = a.Balance; //100
            IDeposit deposit          = new FreeAccountDepositRule();

            deposit.Deposit(a, 10); //stores new balance in account
            TestFileRepo.SaveAccount(a);
            Assert.AreEqual(a.Balance, 110);

            IWithdraw withdraw = new FreeAccountWithdrawRule();

            withdraw.Withdraw(a, -10);
            TestFileRepo.SaveAccount(a);
            Assert.AreEqual(a.Balance, 100);
        }