Ejemplo n.º 1
0
        public void AddInterestToBalance()
        {
            ICustomer customer = new Customer(1, "Name", "Address", "Phone", "Email");

            int          accNumber      = 1;
            double       initialBalance = 123.45;
            IBankAccount account        = BankAccount.CreateBankAccount(customer, accNumber, initialBalance);

            double interest = initialBalance * account.InterestRate;

            DateTime before = DateTime.Now;

            account.AddInterest();
            DateTime after = DateTime.Now;

            Assert.AreEqual(initialBalance + interest, account.Balance);
            Assert.AreEqual(1, account.Transactions.Count);
            ITransaction t = account.Transactions[0];

            Assert.AreEqual(1, t.Id);
            Assert.IsTrue(before <= t.DateTime);
            Assert.IsTrue(after >= t.DateTime);
            Assert.AreEqual("Interest", t.Message);
            Assert.AreEqual(interest, t.Amount);
        }