Ejemplo n.º 1
0
        public void CandyToStringTest()
        {
            DollarAmount dollar = new DollarAmount(0);
            Candy        test   = new Candy("candy", dollar);

            Assert.AreEqual("Enjoy that sugar rush.....before you crash.", test.ToString());
        }
Ejemplo n.º 2
0
        public void DollarAmountToStringTest()
        {
            DollarAmount thisDollarAmount = new DollarAmount(1140);
            string       result           = thisDollarAmount.ToString();

            Assert.AreEqual("$11.40", result);
        }
Ejemplo n.º 3
0
        public void CheckingAccountWithdraw()
        {
            CheckingAccount c1             = new CheckingAccount();
            DollarAmount    depositDollars = new DollarAmount(10000);

            c1.Deposit(depositDollars);
            Assert.AreEqual(depositDollars.totalAmountInCents, c1.Balance.totalAmountInCents);

            DollarAmount withdrawAmount = new DollarAmount(5000);

            c1.Withdraw(withdrawAmount);
            Assert.AreEqual(withdrawAmount.totalAmountInCents, c1.Balance.totalAmountInCents);

            DollarAmount negativeWithdraw = new DollarAmount(6000);
            DollarAmount negativeBalance  = new DollarAmount(-2000);

            c1.Withdraw(negativeWithdraw);
            Assert.AreEqual(negativeBalance.totalAmountInCents, c1.Balance.totalAmountInCents);

            DollarAmount doubleNegativeBalance = new DollarAmount(-9000);

            c1.Withdraw(negativeWithdraw);
            Assert.AreEqual(doubleNegativeBalance.totalAmountInCents, c1.Balance.totalAmountInCents);

            c1.Withdraw(negativeWithdraw);
            Assert.AreEqual(doubleNegativeBalance.totalAmountInCents, c1.Balance.totalAmountInCents);
        }
Ejemplo n.º 4
0
        public void GumToStringTest()
        {
            DollarAmount dollar = new DollarAmount(0);
            Gum          test   = new Gum("gum", dollar);

            Assert.AreEqual("PSA: Peanutbutter removes gum from hair!", test.ToString());
        }
Ejemplo n.º 5
0
        public void WithdrawChecking()
        {
            //$100 - $75
            CheckingAccount example = new CheckingAccount();

            example.Deposit(new DollarAmount(10000));
            example.Withdraw(new DollarAmount(7500));
            DollarAmount expected = new DollarAmount(2500);

            Assert.AreEqual(expected.ToString(), example.Balance.ToString());

            //$100 - $110
            CheckingAccount example1 = new CheckingAccount();

            example1.Deposit(new DollarAmount(10000));
            example1.Withdraw(new DollarAmount(11000));
            DollarAmount expected1 = new DollarAmount(-2000);

            Assert.AreEqual(expected1.ToString(), example1.Balance.ToString());

            //$100 - $500
            CheckingAccount example2 = new CheckingAccount();

            example2.Deposit(new DollarAmount(10000));
            example2.Withdraw(new DollarAmount(50000));
            DollarAmount expected2 = new DollarAmount(10000);

            Assert.AreEqual(expected2.ToString(), example2.Balance.ToString());
        }
Ejemplo n.º 6
0
        public void ToStringTest()
        {
            DollarAmount thisTest = new DollarAmount(90, 50);
            string       results  = thisTest.ToString();

            Assert.AreEqual("$90.50", results);
        }
Ejemplo n.º 7
0
        public void WithdrawSavings()
        {
            //$100 - $50
            SavingsAccount example = new SavingsAccount();

            example.Deposit(new DollarAmount(10000));
            example.Withdraw(new DollarAmount(5000));
            DollarAmount expected = new DollarAmount(4800);

            Assert.AreEqual(expected.ToString(), example.Balance.ToString());

            //$300 - $50
            SavingsAccount example1 = new SavingsAccount();

            example1.Deposit(new DollarAmount(30000));
            example1.Withdraw(new DollarAmount(5000));
            DollarAmount expected1 = new DollarAmount(25000);

            Assert.AreEqual(expected1.ToString(), example1.Balance.ToString());

            //$100 - $150
            SavingsAccount example2 = new SavingsAccount();

            example2.Deposit(new DollarAmount(10000));
            example2.Withdraw(new DollarAmount(15000));
            DollarAmount expected2 = new DollarAmount(10000);

            Assert.AreEqual(expected2.ToString(), example2.Balance.ToString());
        }
Ejemplo n.º 8
0
        public void BeveragesToStringTest()
        {
            DollarAmount dollar = new DollarAmount(0);
            Beverages    test   = new Beverages("beverage", dollar);

            Assert.AreEqual("CAFFEINECAFFEINECAFFEINE!!!", test.ToString());
        }
Ejemplo n.º 9
0
        public void ChipsToStringTest()
        {
            DollarAmount dollar = new DollarAmount(0);
            Chips        test   = new Chips("candy", dollar);

            Assert.AreEqual("Salty goodness.", test.ToString());
        }
Ejemplo n.º 10
0
        public void BankCustomerAccountTest()
        {
            BankCustomer customerTest = new BankCustomer();
            BankAccount  bA1          = new BankAccount();
            BankAccount  bA2          = new BankAccount();

            DollarAmount fittyDolla     = new DollarAmount(5000);
            DollarAmount fiveHunedDolla = new DollarAmount(50000);
            DollarAmount fiveThaouDolla = new DollarAmount(500000);
            DollarAmount fittyThouDolla = new DollarAmount(5000000);

            bA1.Deposit(fiveHunedDolla);
            bA2.Deposit(fittyDolla);

            customerTest.AddAccount(bA1);
            customerTest.AddAccount(bA2);
            BankAccount[] accountArrayTest = { bA1, bA2 };
            CollectionAssert.AreEqual(accountArrayTest, customerTest.Accounts);
            Assert.AreEqual(55000, customerTest.TotalCustBalance.totalAmountInCents);
            Assert.AreEqual(false, customerTest.IsVip);

            BankCustomer customerTest2 = new BankCustomer();
            BankAccount  bA3           = new BankAccount();
            BankAccount  bA4           = new BankAccount();

            bA3.Deposit(fiveThaouDolla);
            bA4.Deposit(fittyThouDolla);

            customerTest2.AddAccount(bA3);
            customerTest2.AddAccount(bA4);
            BankAccount[] accountArrayTest2 = { bA3, bA4 };
            CollectionAssert.AreEqual(accountArrayTest2, customerTest2.Accounts);
            Assert.AreEqual(5500000, customerTest2.TotalCustBalance.totalAmountInCents);
            Assert.AreEqual(true, customerTest2.IsVip);
        }
Ejemplo n.º 11
0
        public void SubtractDollarAmountTest()
        {
            DollarAmount thisDollarAmount       = new DollarAmount(333);
            DollarAmount dollarAmountToSubtract = new DollarAmount(111);
            DollarAmount subtractedAmount       = thisDollarAmount.Minus(dollarAmountToSubtract);

            Assert.AreEqual(222, (subtractedAmount.Dollars * 100) + subtractedAmount.Cents);
        }
Ejemplo n.º 12
0
        public void AddDollarAmountTest()
        {
            DollarAmount thisDollarAmount  = new DollarAmount(111);
            DollarAmount dollarAmountToAdd = new DollarAmount(222);
            DollarAmount addedAmount       = thisDollarAmount.Plus(dollarAmountToAdd);

            Assert.AreEqual(333, (addedAmount.Dollars * 100) + addedAmount.Cents);
        }
Ejemplo n.º 13
0
        public void SavingsAccountOverdraftTest()
        {
            SavingsAccount thisAccount    = new SavingsAccount();
            DollarAmount   withdrawAmount = new DollarAmount(10);
            DollarAmount   lowerBalance   = thisAccount.Withdraw(withdrawAmount);

            Assert.AreEqual(0, lowerBalance.Dollars * 100 + lowerBalance.Cents);
        }
Ejemplo n.º 14
0
        public void CheckingAccountMegaOverdraftTest()
        {
            CheckingAccount thisAccount    = new CheckingAccount();
            DollarAmount    withdrawAmount = new DollarAmount(11111);
            DollarAmount    lowerBalance   = thisAccount.Withdraw(withdrawAmount);

            Assert.AreEqual(0, lowerBalance.Dollars * 100 + lowerBalance.Cents);
        }
Ejemplo n.º 15
0
        public void BankDepositTest()
        {
            BankAccount  thisBankAccount = new BankAccount();
            DollarAmount addingThis      = new DollarAmount(555);
            DollarAmount newBalance      = thisBankAccount.Deposit(addingThis);

            Assert.AreEqual(555, (newBalance.Dollars * 100) + newBalance.Cents);
        }
Ejemplo n.º 16
0
        public void ThisIsADepositTestWithStartingBalanceZero()
        {
            BankAccount  x = new BankAccount();
            DollarAmount amountToDesposit = new DollarAmount(1000);
            DollarAmount newBalance       = x.Deposit(amountToDesposit);

            Assert.AreEqual("$10.00", x.Balance.ToString());
        }
Ejemplo n.º 17
0
        public void CheckForNegativeOneHundredDollars()
        {
            CheckingAccount x = new CheckingAccount();
            DollarAmount    amountToWithdraw = new DollarAmount(10100);

            x.Withdraw(amountToWithdraw);
            Assert.AreEqual("$0.00", x.Balance.ToString());
        }
Ejemplo n.º 18
0
        public void CheckForOverDraft()
        {
            CheckingAccount x = new CheckingAccount();
            DollarAmount    amountToWithdraw = new DollarAmount(1000);

            x.Withdraw(amountToWithdraw);
            Assert.AreEqual("$-20.00", x.Balance.ToString());
        }
        public void DepositIncreasesBalance()
        {
            BankAccount account = new BankAccount("", "");

            DollarAmount newBalance = account.Deposit(new DollarAmount(100));

            Assert.AreEqual(100, newBalance.TotalAmountInCents);
            Assert.AreEqual(100, account.Balance.TotalAmountInCents);
        }
        public void WithdrawDecreasesBalance()
        {
            BankAccount account = new BankAccount("", "");

            DollarAmount newBalance = account.Withdraw(new DollarAmount(100));

            Assert.AreEqual(-100, newBalance.TotalAmountInCents);
            Assert.AreEqual(-100, account.Balance.TotalAmountInCents);
        }
        public void WithdrawPositiveBalance_Test()
        {
            CheckingAccount chkAccount = new CheckingAccount("", "", new DollarAmount(1000));

            DollarAmount newBalance = chkAccount.Withdraw(new DollarAmount(500));

            Assert.AreEqual(500, newBalance.TotalAmountInCents);
            Assert.AreEqual(500, chkAccount.Balance.TotalAmountInCents);
        }
        public void TryToWithdrawFromPositiveBalance()
        {
            SavingsAccount savAcct = new SavingsAccount("", "", new DollarAmount(20000));

            DollarAmount newBalance = savAcct.Withdraw(new DollarAmount(1000));

            Assert.AreEqual(19000, newBalance.TotalAmountInCents);
            Assert.AreEqual(19000, savAcct.Balance.TotalAmountInCents);
        }
        public void TryToWithdrawFromBalanceBelow150()
        {
            SavingsAccount savAcct = new SavingsAccount("", "", new DollarAmount(15100));

            DollarAmount newBalance = savAcct.Withdraw(new DollarAmount(1000));

            Assert.AreEqual(13900, newBalance.TotalAmountInCents);
            Assert.AreEqual(13900, savAcct.Balance.TotalAmountInCents);
        }
        public void SendPositiveIntoNegativeTest()
        {
            SavingsAccount savAcct = new SavingsAccount("", "", new DollarAmount(100));

            DollarAmount newBalance = savAcct.Withdraw(new DollarAmount(200));

            Assert.AreEqual(100, newBalance.TotalAmountInCents);
            Assert.AreEqual(100, savAcct.Balance.TotalAmountInCents);
        }
        public void WithdrawNegativeBalanceBelow100_Test()
        {
            CheckingAccount chkAccount = new CheckingAccount("", "", new DollarAmount(-10000));

            DollarAmount newBalance = chkAccount.Withdraw(new DollarAmount(200));

            Assert.AreEqual(-10000, newBalance.TotalAmountInCents);
            Assert.AreEqual(-10000, chkAccount.Balance.TotalAmountInCents);
        }
Ejemplo n.º 26
0
        public void WithdrawTestTakingTenDollarsAwayFromThirtyDollarBalance()
        {
            BankAccount  x = new BankAccount();
            DollarAmount amountToDeposit  = new DollarAmount(3000);
            DollarAmount newBalance       = x.Deposit(amountToDeposit);
            DollarAmount amountToWithdraw = new DollarAmount(1000);

            newBalance = x.Withdraw(amountToWithdraw);
            Assert.AreEqual("$20.00", x.Balance.ToString());
        }
Ejemplo n.º 27
0
        public void CheckForFeeIfBalanceFallsBelowThresholdAndAboveZero()
        {
            SavingsAccount x = new SavingsAccount();
            DollarAmount   savingsAccountBalance = new DollarAmount(20000);
            DollarAmount   amountToWithdraw      = new DollarAmount(5100);

            x.Deposit(savingsAccountBalance);
            x.Withdraw(amountToWithdraw);
            Assert.AreEqual("$147.00", x.Balance.ToString());
        }
Ejemplo n.º 28
0
        public void IfWithdrawAmountIsMoreThanCurrentBalance()
        {
            SavingsAccount x = new SavingsAccount();
            DollarAmount   savingsAccountBalance = new DollarAmount(20000);
            DollarAmount   amountToWithdraw      = new DollarAmount(20100);

            x.Deposit(savingsAccountBalance);
            x.Withdraw(amountToWithdraw);
            Assert.AreEqual("$200.00", x.Balance.ToString());
        }
Ejemplo n.º 29
0
        public void CheckToSeeIfWithdrawWorksProperlyWhenItDoesntCrossThreshold()
        {
            SavingsAccount x = new SavingsAccount();
            DollarAmount   savingsAccountBalance = new DollarAmount(20000);
            DollarAmount   amountToWithdraw      = new DollarAmount(4900);

            x.Deposit(savingsAccountBalance);
            x.Withdraw(amountToWithdraw);
            Assert.AreEqual("$151.00", x.Balance.ToString());
        }
Ejemplo n.º 30
0
        public void CheckToSeeIfPostWithdrawBalanceIsGreaterThanZero()
        {
            CheckingAccount x = new CheckingAccount();
            DollarAmount    y = new DollarAmount(10000);
            DollarAmount    w = new DollarAmount(5000);

            x.Deposit(y);
            x.Withdraw(w);
            Assert.AreEqual("$50.00", x.Balance.ToString());
        }