Пример #1
0
        public void SavingsAbleToWithDraw()
        {
            SavingsAccount ca = new SavingsAccount(2000);
            ca.WithDrawMoney(1000);

            Assert.AreEqual(950, ca.Balance);
        }
Пример #2
0
        public void SavingsAbleToDeposit()
        {
            SavingsAccount ca = new SavingsAccount(0);
            ca.DepositMoney(1000);

            Assert.AreEqual(1000, ca.Balance);
        }
Пример #3
0
        public void SavingsNotAllowedToOverDraw()
        {
            SavingsAccount ca = new SavingsAccount(100);
            bool result = ca.WithDrawMoney(1000);

            Assert.IsFalse(result);
            Assert.AreEqual(100, ca.Balance);
        }
 protected SavingsAccount GetNewSavingsAccountWHighBalance()
 {
     SavingsAccount newSavingsAccountWHighBalance = new SavingsAccount(70000);
     newSavingsAccountWHighBalance.SnapShotDailyBalance();
     newSavingsAccountWHighBalance.Deposit(60000);
     newSavingsAccountWHighBalance.SnapShotDailyBalance();
     return newSavingsAccountWHighBalance;
 }
Пример #5
0
        public void SavingsAbleToTransferFunds()
        {
            SavingsAccount ca = new SavingsAccount(1200);
            SavingsAccount ca2 = new SavingsAccount(0);
            ca.TransferMoney(ca2, 1000);

            Assert.AreEqual(100, ca.Balance);
            Assert.AreEqual(1000, ca2.Balance);
        }
 protected SavingsAccount GetNewSavingsAccountWLowBalance()
 {
     SavingsAccount newSavingsAccountWLowBalance = new SavingsAccount(100);
     newSavingsAccountWLowBalance.Deposit(50);
     newSavingsAccountWLowBalance.SnapShotDailyBalance();
     newSavingsAccountWLowBalance.Withdraw(45);
     newSavingsAccountWLowBalance.SnapShotDailyBalance();
     return newSavingsAccountWLowBalance;
 }
 public double GetInterestRate(SavingsAccount savingsAccount)
 {
     double interestRate = 0.025;
     double highInterestRate = interestRate + 0.005;
     int thresholdBalance = 50000;
     int thresholdDays = 365 * 5;
     bool isEligibleForHigherRate = savingsAccount.GetAverageDailyBalance() > thresholdBalance
         && (DateTime.Now - savingsAccount.CreatedDate).Days > thresholdDays;
     return isEligibleForHigherRate ? highInterestRate : interestRate;
 }
Пример #8
0
 public void TestConstructorAccount()
 {
     Account testAccount = new SavingsAccount(100);
     Assert.IsNotNull(testAccount, "Constructor of type, SavingsAccount failed to create instance.");
     Assert.AreEqual(100, testAccount.GetBalance(), "Initial amount is not recorded correctly.");
 }
Пример #9
0
 public void TearDown()
 {
     _unitUnderTest = null;
 }
Пример #10
0
 public void SetUp()
 {
     _unitUnderTest = new SavingsAccount(100);
 }
 protected SavingsAccount GetOldSavingsAccountWHighBalance()
 {
     SavingsAccount oldSavingsAccountWHighBalance =
         new SavingsAccount(70000, new DateTime(DateTime.Now.AddYears(-7).Ticks));
     oldSavingsAccountWHighBalance.SnapShotDailyBalance();
     oldSavingsAccountWHighBalance.Deposit(60000);
     oldSavingsAccountWHighBalance.SnapShotDailyBalance();
     return oldSavingsAccountWHighBalance;
 }
 protected SavingsAccount GetOldSavingsAccountLowBalance()
 {
     SavingsAccount oldSavingsAccountLowBalance = new SavingsAccount(150, new DateTime(DateTime.Now.AddYears(-7).Ticks));
     oldSavingsAccountLowBalance.SnapShotDailyBalance();
     oldSavingsAccountLowBalance.Withdraw(45);
     oldSavingsAccountLowBalance.SnapShotDailyBalance();
     return oldSavingsAccountLowBalance;
 }
Пример #13
0
        public static void SavingsMenu()
        {
            SavingsAccount saving = new SavingsAccount(10.00, 0.03);

            ShowSavingsAccountMenu();

            bool exit = false;

            try
            {
                do
                {
                    string input = Console.ReadLine();


                    switch (input.ToUpper())
                    {
                    case "A":
                        Console.WriteLine("--------------------------------------------");
                        Console.WriteLine("How much do you want to deposit?");

                        string a;
                        double depositAmount;

                        a = Console.ReadLine();

                        while (!double.TryParse(a, out depositAmount))
                        {
                            Console.WriteLine("Please enter a number");
                            a = Console.ReadLine();
                        }


                        saving.MakeDeposit(depositAmount);


                        ShowSavingsAccountMenu();
                        break;

                    case "B":
                        Console.WriteLine("--------------------------------------------");
                        Console.WriteLine("How much do you want to withdraw?");

                        string b;
                        double withdrawAmount;

                        b = Console.ReadLine();

                        while (!double.TryParse(b, out withdrawAmount))
                        {
                            Console.WriteLine("Please enter a number");
                            b = Console.ReadLine();
                        }

                        saving.MakeWithdraw(withdrawAmount);

                        ShowSavingsAccountMenu();
                        break;

                    case "C":
                        Console.WriteLine("--------------------------------------------");
                        Console.Write(saving.CloseAndReport());
                        Console.WriteLine("\nPress enter to continue");
                        Console.ReadLine();
                        ShowSavingsAccountMenu();
                        break;

                    case "Q":
                        MainMenu();
                        exit = true;
                        break;

                    default:
                        Console.WriteLine("--------------------------------------------");
                        Console.WriteLine("Please select a valid option: ");
                        ShowSavingsAccountMenu();
                        break;
                    }
                } while (exit == false);
            }catch (Exception)
            {
                Console.WriteLine("Error, try again");
            }
        }
 public void SetUp()
 {
     double initialAmount = 100;
     _unitUnderTest = new SavingsAccount(initialAmount);
 }