forked from kiiadi/abc-bank-c-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankTest.cs
96 lines (78 loc) · 2.74 KB
/
BankTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
namespace AbcBank.Test
{
[TestFixture]
public class BankTest
{
private static readonly double DOUBLE_DELTA = 1e-15;
[Test]
public void Test_CustomerSummary()
{
Bank bank = new Bank();
Customer john = new Customer("John");
john.OpenAccount(new CheckingAccount());
bank.AddCustomer(john);
Assert.AreEqual("Customer Summary\n - John (1 account)", bank.CustomerSummary());
}
[Test]
public void Test_CustomerSummary_ZeroAccounts()
{
Bank bank = new Bank();
Customer john = new Customer("John");
Assert.AreEqual("Customer Summary\n - No accounts found", bank.CustomerSummary());
}
[Test]
public void Test_GetFirstCustomerName()
{
Bank bank = new Bank();
Customer john = new Customer("John");
bank.AddCustomer(john);
Assert.AreEqual("John", bank.GetFirstCustomerName());
}
[Test]
public void Test_GetFirstCustomerName_Exception()
{
Bank bank = new Bank();
Assert.AreEqual("Error", bank.GetFirstCustomerName());
}
[Test]
public void Test_InterestPaid_CheckingAccount()
{
Bank bank = new Bank();
Account checkingAccount = new CheckingAccount();
Customer bill = new Customer("Bill").OpenAccount(checkingAccount);
bank.AddCustomer(bill);
checkingAccount.Deposit(100.0);
Assert.AreEqual(0.1, bank.TotalInterestPaid(), DOUBLE_DELTA);
}
[Test]
public void Test_InterestPaid_SavingsAccount()
{
Bank bank = new Bank();
Account checkingAccount = new SavingsAccount();
bank.AddCustomer(new Customer("Bill").OpenAccount(checkingAccount));
checkingAccount.Deposit(1500.0);
Assert.AreEqual(2.0, bank.TotalInterestPaid(), DOUBLE_DELTA);
}
[Test]
public void Test_InterestPaid_MaxSavings_Account()
{
Bank bank = new Bank();
Account checkingAccount = new MaxSavingsAccount();
bank.AddCustomer(new Customer("Bill").OpenAccount(checkingAccount));
checkingAccount.Deposit(3000.0);
Assert.AreEqual(150.0, bank.TotalInterestPaid(), DOUBLE_DELTA);
}
[Test]
public void Test_InterestPaid_ZeroCustomers()
{
Bank bank = new Bank();
Assert.AreEqual(0.0, bank.TotalInterestPaid());
}
}
}