Beispiel #1
0
        public void DreditFixed_BalanceTooLow() // Debit_Fixed - amount > m_balance  // should fail
        {
            double          amount  = 101.01;   // more than in account (balance)
            double          balance = 100;
            BankAcc_Testing account = new BankAcc_Testing("Mr. Steven Smith", balance);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => account.Debit_Fixed(amount));
        }
Beispiel #2
0
        public void Credit_Zero() // Credit - 0 number// should fail
        {
            double          amount   = 0;
            double          expected = amount;
            BankAcc_Testing account  = new BankAcc_Testing("Mr. Steven Smith", 0);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => account.Credit(amount));
        }
Beispiel #3
0
        public void DreditFixed_Zero()   // Debit_Fixed     - amount == 0          // should fail
        {
            double          amount  = 0; // negative
            double          balance = 100;
            BankAcc_Testing account = new BankAcc_Testing("Mr. Steven Smith", balance);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => account.Debit_Fixed(amount));
        }
Beispiel #4
0
        public void Debit_Negative()           // Debit           - amount<= 0          // should fail
        {
            double          amount  = -101.01; // negative
            double          balance = 100;
            BankAcc_Testing account = new BankAcc_Testing("Mr. Steven Smith", balance);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => account.Debit(amount));
        }
Beispiel #5
0
        public void Balance_PositiveHIGH() // Balance   - positive numbers    // should pass
        {
            double          amount   = 100000000.01;
            double          expected = amount;
            double          actual   = 0.0;
            BankAcc_Testing account  = new BankAcc_Testing("Mr. Steven Smith", amount);

            actual = account.Balance; // expected = 100000000.01
            Assert.AreEqual(expected, actual, 0.001, "Account balance INCORRECT");
        }
Beispiel #6
0
        public void CustomerName() // CustomerName    - name                // should pass
        {
            string          name     = "Mr. Steven Smith";
            string          expected = name;
            string          actual   = "";
            BankAcc_Testing account  = new BankAcc_Testing(name, 0);

            actual = account.CustomerName; // expected = Mr. Steven Smith
            Assert.AreEqual(expected, actual, true, "Account named INCORRECTLY");
        }
Beispiel #7
0
        public void TUTORIAL_Debit_LessThan0_ShouldThrowArgumentOutOfRange()
        {
            // Arrange
            double          beginningBalance = 11.99;
            double          debitAmount      = -100.00;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Bryan Walton", beginningBalance);

            // Shorthand/ lambda expression?
            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => account.Debit(debitAmount));
        }
Beispiel #8
0
        public void Credit() // Credit - positive numbers    // should pass
        {
            double          amount   = 10.01;
            double          expected = amount;
            BankAcc_Testing account  = new BankAcc_Testing("Mr. Steven Smith", 0);

            account.Credit(amount);

            double actual = account.Balance;                                            // expected = 10.01

            Assert.AreEqual(expected, actual, 0.001, "Account not credited correctly"); // should pass
        }
Beispiel #9
0
        public void DreditFixed() // Debit_Fixed - amount < m_balance  // should pass
        {
            double          beginningBalance = 100.10;
            double          debitAmount      = 10.01;
            double          expected         = 90.09;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Steven Smith", beginningBalance);

            account.Debit_Fixed(debitAmount);

            double actual = account.Balance;                                           // expected = 90.09

            Assert.AreEqual(expected, actual, 0.001, "Account not debited correctly"); // should pass
        }
Beispiel #10
0
        public void BankMain() // BankMain - just run and check print // should pass
        {
            BankAcc_Testing account = new BankAcc_Testing("Mr. Steven Smith", 0);

            //account.BankMain();
            BankAcc_Testing.BankMain();
            // Writeline check?

            /*
             * BankAcc4Testing ba = new BankAcc4Testing("Mr. Bryan Walton", 11.99);
             *
             * ba.Credit(5.77);
             * ba.Debit(11.22);
             * Console.WriteLine("Current balance is ${0}", ba.Balance);
             */
        }
Beispiel #11
0
        public void Debit() // Debit           - amount<m_balance  // should pass (will fail due to code)
        {
            // Arrange
            double          beginningBalance = 100.10;
            double          debitAmount      = 10.01;
            double          expected         = 90.09;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Steven Smith", beginningBalance);

            // Act
            account.Debit(debitAmount);

            // Assert
            double actual = account.Balance;                                           // expected = 90.09

            Assert.AreEqual(expected, actual, 0.001, "Account not debited correctly"); // should pass (will fail due to code)
        }
Beispiel #12
0
        public void TUTORIAL_Debit_IncorrectAmount()
        {
            double          debitAmount      = -5;
            double          beginningBalance = 100;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Steven Smith", beginningBalance);

            try
            {
                account.Debit(debitAmount);
            }
            catch (System.ArgumentOutOfRangeException e)
            {
                StringAssert.Contains(e.Message, BankAcc_Testing.Debit_IncorrectAmount_M);
                return;
            }
            Assert.Fail("The expected exception was not thrown.");
        }
Beispiel #13
0
        public void TUTORIAL_FAIL_Debit_Valid_RemainingCheck()
        {
            // Arrange
            double          beginningBalance = 11.99;
            double          debitAmount      = 4.55;
            double          expected         = 7.44;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Bryan Walton", beginningBalance);

            // Act
            account.Debit(debitAmount);

            // Assert
            double actual = account.Balance; // expected = 7.44

            Assert.AreEqual(expected, actual, 0.001, "Account not debited correctly");
            // this uncovers a bug with BankAcc4Testing - m_balance -= amount;
        }
Beispiel #14
0
        public void TUTORIAL_Debit_BalanceTooLow_ShouldThrowArgumentOutOfRange()
        {
            // Arrange
            double          beginningBalance = 11.99;
            double          debitAmount      = 20.0;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Bryan Walton", beginningBalance);

            // Act
            try
            {
                account.Debit(debitAmount);
            }
            catch (System.ArgumentOutOfRangeException e)
            {
                // Assert
                StringAssert.Contains(e.Message, BankAcc_Testing.Debit_AccTooLow_M);
            }
        }
Beispiel #15
0
        public void Balance_Negative() // Balance    - negative numbers    // should fail
        {
            double          amount   = -100.01;
            double          expected = amount;
            double          actual   = 0.0;
            BankAcc_Testing account  = new BankAcc_Testing("Mr. Steven Smith", amount);

            actual = account.Balance;                                              // expected = -100.01
            Assert.AreEqual(expected, actual, 0.001, "Account balance INCORRECT"); // should fail


            double amount2   = 0.0;
            double expected2 = amount2;
            //double actual2 = 0.0;
            BankAcc_Testing account2 = new BankAcc_Testing("Mr. Steven Smith", amount2);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => account.Debit(amount));

            //actual2 = account2.Balance; // expected = 0.0
            //Assert.AreEqual(expected2, actual2, 0.001, "Account balance INCORRECT"); // should fail
        }
Beispiel #16
0
        public void TUTORIAL_Debit_WhenAmountIsMoreThanBalance_ShouldThrowArgumentOutOfRange()
        {
            double          debitAmount      = 101.01; // more than in account (balance)
            double          beginningBalance = 100;
            BankAcc_Testing account          = new BankAcc_Testing("Mr. Steven Smith", beginningBalance);

            //Assert.ThrowsException<System.ArgumentOutOfRangeException>(() => account.Debit(debitAmount));
            // Catch ArgumentOutOfRangeException


            // Try to take more than is in the account
            try
            {
                account.Debit(debitAmount);
            }
            catch (System.ArgumentOutOfRangeException e)
            {
                //throw new ArgumentOutOfRangeException("amount", amount, Debit_IncorrectAmount_M);
                StringAssert.Contains(e.Message, BankAcc_Testing.Debit_AccTooLow_M);
                return; // without return, fails due to carrying on to Assert.Fail
            }
            // When no exception is thrown
            Assert.Fail("Expected exception, but exception was not thrown.");
        }