Skip to content

Commit

Permalink
Multi Currency Money [springframeworkguru#23. Compare Francs with Dol…
Browse files Browse the repository at this point in the history
…lars]
  • Loading branch information
gechulim committed May 5, 2023
1 parent e2a1056 commit bf39b59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/test/java/guru/springframework/Money.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ public class Money {

public boolean equals(Object o) {
Money money = (Money) o;
return amount == money.amount;
return amount == money.amount
&& this.getClass() == money.getClass();
}


Expand Down
10 changes: 6 additions & 4 deletions src/test/java/guru/springframework/MoneyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ void testMultiplicationDollar() {

@Test
void testEqualityDollar() {
assertEquals(new Dollar(6), new Dollar(6));
assertNotEquals(new Dollar(6), new Dollar(8));
assertEquals(new Dollar(5), new Dollar(5));
assertNotEquals(new Dollar(5), new Dollar(8));
assertNotEquals(new Dollar(5), new Franc(5));
}

@Test
Expand All @@ -32,7 +33,8 @@ void testMultiplicationFranc() {

@Test
void testEqualityFranc() {
assertEquals(new Franc(6), new Franc(6));
assertNotEquals(new Franc(6), new Franc(8));
assertEquals(new Franc(5), new Franc(5));
assertNotEquals(new Franc(5), new Franc(8));
assertNotEquals(new Franc(5), new Dollar(5));
}
}

0 comments on commit bf39b59

Please sign in to comment.