forked from nus-cs2103-AY2122S1/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.
Merge pull request #186 from koh-jx/add-Tests
Add tests
- Loading branch information
Showing
11 changed files
with
294 additions
and
3 deletions.
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
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
22 changes: 22 additions & 0 deletions
22
src/test/java/seedu/address/logic/commands/RedoCommandTest.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,22 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
import static seedu.address.testutil.TypicalTasks.getTypicalTaskList; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
class RedoCommandTest { | ||
|
||
private final Model model = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
|
||
@Test | ||
void execute_invalid_undo() { | ||
RedoCommand redoCommand = new RedoCommand(); | ||
CommandTestUtil.assertCommandSuccess(redoCommand, model, RedoCommand.MESSAGE_NOT_UNDONE, model); | ||
} | ||
|
||
} |
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
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
69 changes: 69 additions & 0 deletions
69
src/test/java/seedu/address/logic/commands/task/PurgeTaskCommandTest.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,69 @@ | ||
package seedu.address.logic.commands.task; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
import static seedu.address.testutil.TypicalTasks.getTypicalTaskList; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.ClearCommand; | ||
import seedu.address.logic.commands.UndoCommand; | ||
import seedu.address.logic.commands.UndoableCommand; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.TaskList; | ||
import seedu.address.model.UserPrefs; | ||
|
||
class PurgeTaskCommandTest { | ||
|
||
@Test | ||
void execute_emptyAddressBook_failure() { | ||
Model model = new ModelManager(); | ||
Model expectedModel = new ModelManager(); | ||
|
||
assertCommandFailure(new PurgeTaskCommand(), model, PurgeTaskCommand.MESSAGE_NO_TASK_TO_PURGE); | ||
} | ||
|
||
@Test | ||
void execute_unfilteredAddressBook_success() { | ||
Model model = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
Model expectedModel = new ModelManager(getTypicalAddressBook(), new TaskList(), new UserPrefs()); | ||
|
||
assertCommandSuccess(new PurgeTaskCommand(), model, PurgeTaskCommand.MESSAGE_SUCCESS, expectedModel); | ||
} | ||
|
||
@Test | ||
void undo_unfilteredPurgedAddressBook_success() { | ||
Model model = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
Model expectedModel = new ModelManager(getTypicalAddressBook(), new TaskList(), new UserPrefs()); | ||
|
||
UndoableCommand purgeTask = new PurgeTaskCommand(); | ||
assertCommandSuccess(purgeTask, model, PurgeTaskCommand.MESSAGE_SUCCESS, expectedModel); | ||
model.getCommandHistory().pushCommand(purgeTask); | ||
|
||
Model originalModel = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
String successMessage = UndoCommand.MESSAGE_UNDO_SUCCESS + PurgeTaskCommand.MESSAGE_SUCCESS; | ||
assertCommandSuccess(new UndoCommand(), model, successMessage, originalModel); | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
final PurgeTaskCommand standardCommand = new PurgeTaskCommand(); | ||
|
||
// same object -> returns true | ||
assertTrue(standardCommand.equals(standardCommand)); | ||
|
||
// null -> returns false | ||
assertFalse(standardCommand.equals(null)); | ||
|
||
// different types -> returns false | ||
assertFalse(standardCommand.equals(new ClearCommand())); | ||
|
||
// different object, same type -> returns true | ||
assertTrue(standardCommand.equals(new PurgeTaskCommand())); | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
src/test/java/seedu/address/logic/commands/task/SetTaskCommandTest.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,57 @@ | ||
package seedu.address.logic.commands.task; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
import static seedu.address.testutil.TypicalTasks.getTypicalTaskList; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.UndoCommand; | ||
import seedu.address.logic.commands.UndoableCommand; | ||
import seedu.address.model.AddressBook; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.TaskList; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.task.Task; | ||
import seedu.address.testutil.TaskBuilder; | ||
|
||
class SetTaskCommandTest { | ||
@Test | ||
void execute_setTaskAsNewTask_success() { | ||
Model model = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
Task newTask = new TaskBuilder().build(); | ||
|
||
String expectedMessage = String.format(EditTaskCommand.MESSAGE_EDIT_TASK_SUCCESS, newTask); | ||
Task task = model.getTaskList().getTasks().get(INDEX_FIRST_PERSON.getZeroBased()); | ||
|
||
Model expectedModel = new ModelManager( | ||
new AddressBook(model.getAddressBook()), new TaskList(model.getTaskList()), new UserPrefs()); | ||
expectedModel.setTask(task, newTask); | ||
|
||
assertCommandSuccess(new SetTaskCommand(task, newTask), model, expectedMessage, expectedModel); | ||
} | ||
|
||
@Test | ||
void undo_unfilteredSetAddressBook_success() { | ||
Model model = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
Task newTask = new TaskBuilder().build(); | ||
|
||
String expectedMessage = String.format(EditTaskCommand.MESSAGE_EDIT_TASK_SUCCESS, newTask); | ||
Task task = model.getTaskList().getTasks().get(INDEX_FIRST_PERSON.getZeroBased()); | ||
|
||
Model expectedModel = new ModelManager( | ||
new AddressBook(model.getAddressBook()), new TaskList(model.getTaskList()), new UserPrefs()); | ||
expectedModel.setTask(task, newTask); | ||
UndoableCommand setTaskCommand = new SetTaskCommand(task, newTask); | ||
|
||
assertCommandSuccess(setTaskCommand, model, expectedMessage, expectedModel); | ||
model.getCommandHistory().pushCommand(setTaskCommand); | ||
|
||
Model originalModel = new ModelManager(getTypicalAddressBook(), getTypicalTaskList(), new UserPrefs()); | ||
String successMessage = UndoCommand.MESSAGE_UNDO_SUCCESS + expectedMessage; | ||
assertCommandSuccess(new UndoCommand(), model, successMessage, originalModel); | ||
} | ||
|
||
} |
Oops, something went wrong.