forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tests for Sort Commands and the Sort function in models
- Loading branch information
1 parent
391da1b
commit b82bd52
Showing
6 changed files
with
223 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/seedu/address/logic/commands/appointmentcommands/SortCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package seedu.address.logic.commands.appointmentcommands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalAppointments.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
|
||
public class SortCommandTest { | ||
private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
@Test | ||
public void execute_sortList_success() { | ||
Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
expectedModel.sortAppointmentList(true, "time"); | ||
|
||
assertCommandSuccess(new SortCommand(true, "time"), | ||
model, String.format(SortCommand.MESSAGE_SUCCESS, "ascending", "time"), expectedModel); | ||
} | ||
@Test | ||
public void equals() { | ||
SortCommand sortFirstCommand = new SortCommand(true, "time"); | ||
SortCommand sortSecondCommand = new SortCommand(false, "priority"); | ||
|
||
// same object -> returns true | ||
assertTrue(sortFirstCommand.equals(sortFirstCommand)); | ||
|
||
// same values -> returns true | ||
SortCommand sortFirstCommandCopy = new SortCommand(true, "time"); | ||
assertTrue(sortFirstCommand.equals(sortFirstCommandCopy)); | ||
|
||
// different types -> returns false | ||
assertFalse(sortFirstCommand.equals(1)); | ||
|
||
// null -> returns false | ||
assertFalse(sortFirstCommand.equals(null)); | ||
|
||
// different appointment -> returns false | ||
assertFalse(sortFirstCommand.equals(sortSecondCommand)); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/seedu/address/logic/commands/personcommands/SortPatientCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package seedu.address.logic.commands.personcommands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
|
||
public class SortPatientCommandTest { | ||
private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
|
||
@Test | ||
public void execute_sortList_success() { | ||
Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
boolean isAscending = false; | ||
expectedModel.sortPatientList(isAscending, "name"); | ||
|
||
assertCommandSuccess(new SortPatientCommand(isAscending, "name"), | ||
model, String.format(SortPatientCommand.MESSAGE_SUCCESS, | ||
"descending", "name"), expectedModel); | ||
} | ||
@Test | ||
public void equals() { | ||
SortPatientCommand sortPatientFirstCommand = new SortPatientCommand(true, "name"); | ||
SortPatientCommand sortPatientSecondCommand = new SortPatientCommand(false, "birthday"); | ||
|
||
// same object -> returns true | ||
assertTrue(sortPatientFirstCommand.equals(sortPatientFirstCommand)); | ||
|
||
// same values -> returns true | ||
SortPatientCommand sortPatientFirstCommandCopy = new SortPatientCommand(true, "name"); | ||
assertTrue(sortPatientFirstCommand.equals(sortPatientFirstCommandCopy)); | ||
|
||
// different types -> returns false | ||
assertFalse(sortPatientFirstCommand.equals(1)); | ||
|
||
// null -> returns false | ||
assertFalse(sortPatientFirstCommand.equals(null)); | ||
|
||
// different appointment -> returns false | ||
assertFalse(sortPatientFirstCommand.equals(sortPatientSecondCommand)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,12 @@ public class TypicalPersons { | |
.withEmail("[email protected]").withPhone("98765432") | ||
.withBirthdate("2001/10/20") | ||
.withTags("owesMoney", "friends").build(); | ||
public static final Person LOWERCASE_BENJAMIN = new PersonBuilder().withName("benjamin Monk") | ||
.withGender("MALE") | ||
.withAddress("311, Clementi Ave 2, #02-25") | ||
.withEmail("[email protected]").withPhone("98765432") | ||
.withBirthdate("2001/10/16") | ||
.withTags("cancer", "diabetes").build(); | ||
public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withGender("MALE") | ||
.withPhone("95352563").withEmail("[email protected]").withBirthdate("1987/01/02") | ||
.withAddress("wall street").withTags("malaria").build(); | ||
|