PR
This commit is contained in:
@@ -16,7 +16,7 @@ class Voucher {
|
||||
return true;
|
||||
if (!(o instanceof Voucher))
|
||||
return false;
|
||||
Voucher other = (Voucher)o;
|
||||
Voucher other = (Voucher) o;
|
||||
boolean valueEquals = (this.value == null && other.value == null)
|
||||
|| (this.value != null && this.value.equals(other.value));
|
||||
boolean storeEquals = (this.store == null && other.store == null)
|
||||
|
||||
@@ -13,15 +13,25 @@ public class MoneyUnitTest {
|
||||
Money expenses = new Money(55, "USD");
|
||||
|
||||
assertTrue(income.equals(expenses));
|
||||
assertTrue(expenses.equals(income));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenMoneyAndWrongVoucherInstances_whenEquals_thenReturnValuesArentSymmetric() {
|
||||
Money money = new Money(42, "USD");
|
||||
WrongVoucher voucher = new WrongVoucher(42, "USD", "Amazon");
|
||||
|
||||
assertFalse(voucher.equals(money));
|
||||
assertTrue(money.equals(voucher));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenMoneyAndVoucherInstances_whenEquals_thenReturnValuesArentSymmetric() {
|
||||
Money cash = new Money(42, "USD");
|
||||
WrongVoucher voucher = new WrongVoucher(42, "USD", "Amazon");
|
||||
Money money = new Money(42, "USD");
|
||||
Voucher voucher = new Voucher(42, "USD", "Amazon");
|
||||
|
||||
assertFalse(voucher.equals(cash));
|
||||
assertTrue(cash.equals(voucher));
|
||||
assertFalse(voucher.equals(money));
|
||||
assertFalse(money.equals(voucher));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user