blob: 0c7357a57949b70673e642be1c20357db6990981 (
plain)
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
|
using System;
using DesignPatterns.Test;
using MbUnit.Framework;
namespace DesignPatterns.Factory {
[TestFixture]
public class BankAccountTest {
[Test]
public void Should_Create_A_Cibc_Chequing_Account( ) {
IBank bank = new CibcBank( );
IBankAccountFactory factory = bank.GetAccountFactory( );
IBankAccount chequingAccount = factory.CreateChequingAccount( );
Assert.IsTrue( chequingAccount.Balance.Amount == 0, "Should be zero but was: " + chequingAccount.Balance.Amount );
}
[Test]
public void Should_Create_A_Cibc_Savings_Account( ) {
IBank bank = new CibcBank( );
IBankAccountFactory factory = bank.GetAccountFactory( );
IBankAccount savingsAccount = factory.CreateSavingsAccount( );
Assert.IsTrue( savingsAccount.Balance.Amount == 0, "Should be zero but was: " + savingsAccount.Balance.Amount );
}
[Test]
public void Should_Create_A_Royal_Bank_Chequing_Account( ) {
IBank bank = new RoyalBank( );
IBankAccountFactory factory = bank.GetAccountFactory( );
IBankAccount chequingAccount = factory.CreateChequingAccount( );
Assert.IsTrue( chequingAccount.Balance.Amount == 0, "Should be zero but was: " + chequingAccount.Balance.Amount );
}
[Test]
public void Should_Create_A_Royal_Bank_Savings_Account( ) {
IBank bank = new RoyalBank( );
IBankAccountFactory factory = bank.GetAccountFactory( );
IBankAccount savingsAccount = factory.CreateSavingsAccount( );
Assert.IsTrue( savingsAccount.Balance.Amount == 0, "Should be zero but was: " + savingsAccount.Balance.Amount );
}
[Test]
public void _Should_Have_A_Balance( ) {
IBankAccount account = new BankAccount( new Money( 5 ) );
Assert.IsTrue( account.Balance.Equals( new Money( 5 ) ) );
}
[Test]
public void Should_Have_Account_Number( ) {
string accountNumber = Guid.NewGuid( ).ToString( );
IBankAccount account = new BankAccount( new Money( 500 ), accountNumber );
Assert.IsTrue( accountNumber == account.AccountNumber );
}
}
}
|