Beispiel #1
0
        public void BankAccountAccrueOrChargeInterestAccrueSavingsRateIfBalanceIsPositive()
        {
            BankAccount account = new BankAccount()
            {
                SavingsRate = 0.01M
            };

            account.Deposit(50);

            account.AccrueOrChargeInterest();

            Assert.AreEqual(50.5M, account.Balance);

            UnitTest test = Factory.CreateTest();
            TestVariable <BankAccount> _account = test.CreateVariable <BankAccount>();

            test.Arrange(_account, Expr(() => new BankAccount()
            {
                SavingsRate = 0.01M
            }));
            test.Act(Expr(_account, a => a.Deposit(50M)));
            test.Act(Expr(_account, a => a.AccrueOrChargeInterest()));
            test.Assert.AreEqual(Const(50.5M), Expr(_account, a => a.Balance));
            test.Execute();
        }
Beispiel #2
0
        public void BankAccountAccrueOrChargeInterestChargesBorrowingRateIfBalanceIsNegative()
        {
            BankAccount account = new BankAccount()
            {
                BorrowingRate = 0.1M
            };

            account.Withdraw(50);

            account.AccrueOrChargeInterest();

            Assert.AreEqual(-45.0M, account.Balance);

            // TestTools Code
            UnitTest test = Factory.CreateTest();
            TestVariable <BankAccount> _account = test.CreateVariable <BankAccount>();

            test.Arrange(_account, Expr(() => new BankAccount()
            {
                BorrowingRate = 0.1M
            }));
            test.Act(Expr(_account, a => a.Withdraw(50M)));
            test.Act(Expr(_account, a => a.AccrueOrChargeInterest()));
            test.Assert.AreEqual(Const(-45.0M), Expr(_account, a => a.Balance));
            test.Execute();
        }
Beispiel #3
0
        public void BankAccountAccrueOrChargeInterestDoesNotAffectBalanceIfBalanceEqualsZero()
        {
            BankAccount account = new BankAccount();

            account.AccrueOrChargeInterest();

            Assert.AreEqual(0M, account.Balance);

            // TestTools Code
            UnitTest test = Factory.CreateTest();
            TestVariable <BankAccount> _account = test.CreateVariable <BankAccount>();

            test.Arrange(_account, Expr(() => new BankAccount()));
            test.Act(Expr(_account, a => a.AccrueOrChargeInterest()));
            test.Assert.AreEqual(Const(0M), Expr(_account, a => a.Balance));
            test.Execute();
        }