[Test] //Test customer statement generation public void TestRenderCustomerStatement() { TextCustomerRenderer renderer = new TextCustomerRenderer(); IAccountFactory accountFactory = new AccountFactory(DateProvider.getInstance()); Account checkingAccount = accountFactory.CreateAccount(AccountType.CHECKING); Account savingsAccount = accountFactory.CreateAccount(AccountType.SAVINGS); Customer henry = new Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount); checkingAccount.deposit(100.0); savingsAccount.deposit(4000.0); savingsAccount.withdraw(200.0); Assert.AreEqual("Statement for Henry\n" + "\n" + "Checking Account\n" + " deposit $100.00\n" + "Total $100.00\n" + "\n" + "Savings Account\n" + " deposit $4,000.00\n" + " withdrawal $200.00\n" + "Total $3,800.00\n" + "\n" + "Total In All Accounts $3,900.00", renderer.Render(henry)); }
public void TestCreateCheckingAccount() { AccountFactory factory = new AccountFactory(DateProvider.getInstance()); Account account = factory.CreateAccount(AccountType.CHECKING); Assert.IsNotNull(account); Assert.AreEqual(AccountType.CHECKING, account.AccountType); }
public void TestCreateMaxiSavingAccount() { AccountFactory factory = new AccountFactory(DateProvider.getInstance()); Account account = factory.CreateAccount(AccountType.MAXI_SAVINGS); Assert.IsNotNull(account); Assert.AreEqual(AccountType.MAXI_SAVINGS, account.AccountType); }
public void TestRenderCustomerSummary() { TextBankRenderer renderer = new TextBankRenderer(); Bank bank = new Bank(); Customer john = new Customer("John"); IAccountFactory accountFactory = new AccountFactory(DateProvider.getInstance()); john.openAccount(accountFactory.CreateAccount(AccountType.CHECKING)); bank.addCustomer(john); Assert.AreEqual("Customer Summary\n - John (1 account)", renderer.Render(bank)); }
public void transactionDate_is_set_manually() { // prime the date DateTime d = DateTime.Now.AddDays(-365); DateProvider.getInstance().SetBackDate(d); Transaction t = new Transaction(5); // reset the date DateProvider.getInstance().SetBackDate(DateTime.MinValue); // check that the date of the transaction is 365 days ago. Assert.AreEqual(d, t.transactionDate); }
public void accounttype_maxi_savings_interestrate_withdrawl_more_then_10_days_test() { // set the date back so all transactions have back a year DateProvider.getInstance().SetBackDate(DateTime.Now.AddDays(-365)); Customer bill = new Customer("Bill").openAccount(AccountType.MAXI_SAVING); bill.deposit(AccountType.MAXI_SAVING, 3000.0); bill.withdraw(AccountType.MAXI_SAVING, 100); // reset it DateProvider.getInstance().SetBackDate(DateTime.MinValue); Assert.AreEqual(2900 * 0.05, bill.totalInterestEarned(), DOUBLE_DELTA); }
public void TestGettingNowDateShouldBeUTCCurrentDateTime() { DateProvider provider = DateProvider.getInstance(); Assert.IsNotNull(provider); DateTime now = DateTime.UtcNow; DateTime date = provider.now(); Assert.IsFalse(date == default(DateTime)); Assert.IsTrue(date.Kind == DateTimeKind.Utc); Assert.AreEqual(now.Year, date.Year); Assert.AreEqual(now.Month, date.Month); Assert.AreEqual(now.Day, date.Day); Assert.AreEqual(now.Hour, date.Hour); Assert.AreEqual(now.Minute, date.Minute); Assert.AreEqual(now.Hour, date.Hour); Assert.AreEqual(now.Minute, date.Minute); Assert.AreEqual(now.Second, date.Second); }
protected override Account InstantiateAccount() { return(new Account(AccountType.CHECKING, new CheckingInterestCalculator(), DateProvider.getInstance())); }
public void TestDateProviderInstanceNotNull() { Assert.IsNotNull(DateProvider.getInstance()); }
protected override Account InstantiateAccount() { return(new Account(AccountType.SAVINGS, new SavingInterestCalculator(), DateProvider.getInstance())); }