forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ecc94f
commit dea32b5
Showing
2 changed files
with
53 additions
and
2 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
51 changes: 51 additions & 0 deletions
51
src/test/java/seedu/address/logic/commands/LeaveCommandTest.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,51 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.person.Person; | ||
|
||
public class LeaveCommandTest { | ||
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
private LeaveCommand leaveFirstCommand = new LeaveCommand(INDEX_FIRST_PERSON, "0000+0000000"); | ||
private LeaveCommand leaveSecondCommand = new LeaveCommand(INDEX_SECOND_PERSON, "0+0000000000"); | ||
|
||
@Test | ||
public void equals() { | ||
assertFalse(leaveFirstCommand.equals(null)); | ||
assertEquals(leaveFirstCommand, leaveFirstCommand); | ||
assertFalse(leaveFirstCommand.equals(leaveSecondCommand)); | ||
assertFalse(leaveFirstCommand.toString().equals("")); | ||
} | ||
|
||
@Test | ||
public void execute_success() { | ||
Person person = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); | ||
String expected = String.format(LeaveCommand.MESSAGE_LEAVE_SUCCESS, Messages.format(person)); | ||
ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); | ||
assertCommandSuccess(leaveFirstCommand, model, expected, expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_failure() { | ||
Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); | ||
LeaveCommand command = new LeaveCommand(outOfBoundIndex, "0000+0000000"); | ||
assertCommandFailure(command, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
|
||
Person person = model.getFilteredPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); | ||
assertCommandFailure(leaveSecondCommand, model, | ||
String.format(LeaveCommand.MESSAGE_NOT_EDITED, person.getLeave().toString())); | ||
} | ||
} |