Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
solomonng2001 committed Mar 29, 2024
1 parent d786cec commit 3a5aefa
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/model/reminder/ReminderList.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public boolean equals(Object other) {
return false;
}

if (!remindersList.equals(otherReminderList.remindersList)) {
return false;
}

return true;
}
}
5 changes: 5 additions & 0 deletions src/test/java/seedu/address/model/person/PersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ public void scheduleStringFormat() {
missedAlice.scheduleStringFormat());
}

@Test
public void birthdayStringFormat() {
assertEquals(ALICE.birthdayStringFormat(), ALICE.getBirthday() + " - " + ALICE.getName());
}

@Test
public void hasUpcomingBirthday() {
Person upcomingAlice = new PersonBuilder(ALICE).withBirthday(DateUtil.parseDateToString(
Expand Down
71 changes: 71 additions & 0 deletions src/test/java/seedu/address/model/reminder/ReminderListTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.model.reminder;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.testutil.TypicalPersons.ALICE;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -9,6 +10,7 @@

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.commons.util.DateUtil;
import seedu.address.model.person.Person;
import seedu.address.testutil.PersonBuilder;

Expand Down Expand Up @@ -38,4 +40,73 @@ public void toStringMethodSchedule() {
assertEquals(reminderList.toString(), person1.scheduleStringFormat()
+ "\n" + person2.scheduleStringFormat() + "\n");
}

@Test
public void toStringMethodBirthday() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
Person person1 = new PersonBuilder().withBirthday(DateUtil.parseDateToString(
LocalDate.of(2001, 1, 1))).build();
remindersList.add(person1);
Person person2 = new PersonBuilder().withBirthday(DateUtil.parseDateToString(
LocalDate.of(2002, 2, 2))).build();
remindersList.add(person2);
ReminderList reminderList = new ReminderList(ReminderType.BIRTHDAYS, remindersList);
assertEquals(reminderList.toString(), person1.birthdayStringFormat()
+ "\n" + person2.birthdayStringFormat() + "\n");
}

@Test
public void equals_sameObject_true() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
ReminderList reminderList = new ReminderList(ReminderType.LAST_MET, remindersList);
assertEquals(reminderList, reminderList);
}

@Test
public void equals_sameValues_true() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList);
ReminderList reminderList2 = new ReminderList(ReminderType.LAST_MET, remindersList);
assertEquals(reminderList1, reminderList2);
}

@Test
public void equals_differentType_false() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
ReminderList reminderList = new ReminderList(ReminderType.LAST_MET, remindersList);
assertEquals(reminderList.equals(1), false);
}

@Test
public void equals_differentReminderType_false() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList);
ReminderList reminderList2 = new ReminderList(ReminderType.SCHEDULES, remindersList);
assertEquals(reminderList1.equals(reminderList2), false);
}

@Test
public void equals_null_false() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
ReminderList reminderList = new ReminderList(ReminderType.LAST_MET, remindersList);
assertEquals(reminderList.equals(null), false);
}

@Test
public void equals_differentRemindersList_false() {
ObservableList<Person> remindersList1 = FXCollections.observableArrayList();
ObservableList<Person> remindersList2 = FXCollections.observableArrayList();
remindersList2.add(ALICE);
ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList1);
ReminderList reminderList2 = new ReminderList(ReminderType.LAST_MET, remindersList2);
assertEquals(reminderList1.equals(reminderList2), false);
}

@Test
public void equals_sameRemindersList_true() {
ObservableList<Person> remindersList = FXCollections.observableArrayList();
ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList);
ReminderList reminderList2 = new ReminderList(ReminderType.LAST_MET, remindersList);
assertEquals(reminderList1.equals(reminderList2), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class ReminderTypeTest {
public void toStringMethod() {
assertEquals("Last Met", ReminderType.LAST_MET.toString());
assertEquals("Schedules", ReminderType.SCHEDULES.toString());
assertEquals("Birthday", ReminderType.BIRTHDAYS.toString());
}
}

0 comments on commit 3a5aefa

Please sign in to comment.