diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 65719b8d66b..1d7256a8c11 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -56,25 +56,61 @@ public void isSamePerson() { public void hasSameEmail() { assertTrue(ALICE.hasSameEmail(ALICE)); + // same name, different email -> return false Person editedAlice = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); assertFalse(ALICE.hasSameEmail(editedAlice)); + assertTrue(editedAlice.hasSameEmail(BOB)); + // different name, same email -> return true Person editedBob = new PersonBuilder(BOB).withEmail(VALID_EMAIL_AMY).build(); Person aliceWithNewEmail = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_AMY).build(); assertTrue(aliceWithNewEmail.hasSameEmail(editedBob)); + // null -> always return false assertFalse(ALICE.hasSameEmail(null)); } + @Test + public void hasSamePhoneNumber() { + assertTrue(ALICE.hasSamePhoneNumber(ALICE)); + assertFalse(ALICE.hasSamePhoneNumber(BOB)); + + // different name, same phone number -> return true + Person editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).build(); + assertTrue(editedAlice.hasSamePhoneNumber(BOB)); + + //same name, different phone number -> return false + assertFalse(editedAlice.hasSamePhoneNumber(ALICE)); + + //null -> always return false + assertFalse(ALICE.hasSamePhoneNumber(null)); + } + @Test public void hasDuplicateInfo() { assertTrue(ALICE.hasDuplicateInfo(ALICE)); assertFalse(ALICE.hasDuplicateInfo(null)); + // Different name, phone, same email Person editedBob = new PersonBuilder(BOB).withEmail(VALID_EMAIL_AMY).build(); Person aliceWithNewEmail = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_AMY).build(); assertTrue(editedBob.hasDuplicateInfo(aliceWithNewEmail)); assertFalse(editedBob.hasDuplicateInfo(ALICE)); + + // Different email, phone, same phone + Person editedBob2 = new PersonBuilder(BOB).withPhone(VALID_PHONE_BOB).build(); + Person aliceWithNewEmail2 = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).build(); + assertTrue(editedBob2.hasDuplicateInfo(aliceWithNewEmail2)); + assertFalse(editedBob2.hasDuplicateInfo(ALICE)); + + // Different email, name, same name + Person editedBob3 = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); + Person aliceWithNewEmail3 = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).build(); + assertTrue(editedBob3.hasDuplicateInfo(aliceWithNewEmail3)); + assertTrue(editedBob3.hasDuplicateInfo(BOB)); + + //NULL + assertFalse(editedBob3.hasDuplicateInfo(null)); } @Test