Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ararchch committed Apr 3, 2024
1 parent ede9311 commit 246e4e9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showAppointmentAtIndex;
import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_1;
import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_2;
import static seedu.address.testutil.TypicalAppointments.getTypicalAddressBook;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_APPOINTMENT;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_APPOINTMENT;
Expand Down Expand Up @@ -183,4 +184,12 @@ public void toStringMethod() {
assertEquals(expected, editAppointmentCommand.toString());
}

@Test
public void getPatientNric_returnsNricAsOptional() {
model.addAppointment(APPOINTMENT_2);
Index idx = Index.fromOneBased(1);
EditAppointmentDescriptor descriptor = new EditAppointmentDescriptorBuilder().withDate("2124-03-19").build();
EditAppointmentCommand editAppointmentCommand = new EditAppointmentCommand(idx, descriptor);
}

}
25 changes: 25 additions & 0 deletions src/test/java/seedu/address/model/AddressBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_1;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -18,6 +20,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.model.appointment.Appointment;
import seedu.address.model.appointment.exceptions.DuplicateAppointmentException;
import seedu.address.model.person.Nric;
import seedu.address.model.person.Person;
import seedu.address.model.person.exceptions.DuplicatePersonException;
Expand Down Expand Up @@ -135,4 +138,26 @@ public void getPersonByNric_addressbookIsEmpty_throwsPersonNotFoundException() {
assertThrows(PersonNotFoundException.class, () -> addressBook.getPersonByNric(ALICE.getNric()));
}

@Test
public void hasPersonNric_validNric_returnsTrue() {
addressBook.addPerson(ALICE);
assertTrue(addressBook.hasPersonNric(ALICE.getNric().toString()));
}

@Test
public void setAppointments_validSet_setsAppointments() throws DuplicateAppointmentException {
List<Appointment> appts = new ArrayList<>();
appts.add(APPOINTMENT_1);
addressBook.setAppointments(appts);
assertTrue(addressBook.hasAppointment(APPOINTMENT_1));
}

@Test
public void equalsMethod() {
// same object
assertTrue(addressBook.equals(addressBook));
// different class
assertFalse(addressBook.equals(APPOINTMENT_1));
}

}

0 comments on commit 246e4e9

Please sign in to comment.