-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathBankTest.scala
More file actions
49 lines (40 loc) · 1.54 KB
/
BankTest.scala
File metadata and controls
49 lines (40 loc) · 1.54 KB
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
package com.abc
import org.scalatest.{Matchers, FlatSpec}
class BankTest extends FlatSpec with Matchers {
"Bank" should "customer summary" in {
val bank: Bank = new Bank
var john: Customer = new Customer("John").openAccount(new CheckingAccount)
bank.addCustomer(john)
bank.customerSummary should be("Customer Summary\n - John (1 account)")
}
it should "checking account" in {
val bank: Bank = new Bank
val checkingAccount: Account = new CheckingAccount
val bill: Customer = new Customer("Bill").openAccount(checkingAccount)
bank.addCustomer(bill)
checkingAccount.deposit(100.0)
bank.totalInterestPaid should be(0.1)
}
it should "savings account" in {
val bank: Bank = new Bank
val savingAccount: Account = new SavingAccount
bank.addCustomer(new Customer("Bill").openAccount(savingAccount))
savingAccount.deposit(1500.0)
bank.totalInterestPaid should be(2.0)
}
it should "maxi savings account without withdrawal in the last 10 days" in {
val bank: Bank = new Bank
val maxiAccount: Account = new MaxiSavingAccount
bank.addCustomer(new Customer("Bill").openAccount(maxiAccount))
maxiAccount.deposit(3000.0)
bank.totalInterestPaid should be(150.0)
}
it should "maxi savings account with recent withdrawal" in {
val bank: Bank = new Bank
val maxiAccount: Account = new MaxiSavingAccount
bank.addCustomer(new Customer("Bill").openAccount(maxiAccount))
maxiAccount.deposit(3000.0)
maxiAccount.withdraw(100.0)
bank.totalInterestPaid should be(2.9)
}
}