コード例 #1
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);
        }
コード例 #2
0
        public void CanEditFileAccount()
        {
            FileAccountRepository repo = new FileAccountRepository(_testDataPath);

            Account updatedAcct = new Account
            {
                AccountNumber = "11111",
                Name          = "Free Customer",
                Balance       = 1000m,
                Type          = AccountType.Free
            };

            repo.SaveAccount(updatedAcct);

            List <Account> updatedAccounts = repo.GetAccountsFromFile(_testDataPath);

            Account modifiedAcct = updatedAccounts.Single(a => a.AccountNumber == "11111");

            Assert.AreEqual(updatedAcct.Balance, modifiedAcct.Balance); //balance should be raised to 1000m
        }