Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update unit test for duplicate information detection #75

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/test/java/seedu/address/model/person/PersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down