Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxunn committed Oct 24, 2023
1 parent 7236d76 commit d9745ff
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/java/seedu/address/logic/commands/CommandResultTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ public void hashcode() {
// different exit value -> returns different hashcode
assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", false, true, "exit").hashCode());
}
@Test
public void stateTest() {
CommandResult commandResult = new CommandResult("feedback", true, false, "view");
assertEquals("view", commandResult.checkState());
}

@Test
public void notEqualsTest() {
CommandResult commandResult1 = new CommandResult("feedback", true, true, "view");
CommandResult commandResult2 = new CommandResult("differentFeedback", true, true, "help");
assertNotEquals(commandResult1, commandResult2);
}
@Test
public void defaultConstructorTest() {
CommandResult commandResult = new CommandResult("feedback");
assertFalse(commandResult.isShowHelp());
assertFalse(commandResult.isExit());
assertEquals("null", commandResult.checkState());
}
@Test
public void hashCodeConsistencyTest() {
CommandResult commandResult = new CommandResult("feedback", true, false, "state");
assertEquals(commandResult.hashCode(), commandResult.hashCode());
}

@Test
public void toStringMethod() {
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/seedu/address/logic/commands/ViewCommandTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package seedu.address.logic.commands;

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.TypicalIndexes.INDEX_FIRST_PERSON;
Expand Down Expand Up @@ -29,6 +31,21 @@ public void setUp() {
expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
}

@Test
public void equals() {
Index index1 = Index.fromOneBased(1);
Index index2 = Index.fromOneBased(2);

ViewCommand viewCommand1 = new ViewCommand(index1);
ViewCommand viewCommand2 = new ViewCommand(index2);

assertTrue(viewCommand1.equals(viewCommand1));

assertFalse(viewCommand1.equals(viewCommand2));

assertFalse(viewCommand1.equals(5));
}

@Test
public void execute_invalidIndex_throwsCommandException() {
Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1);
Expand All @@ -47,3 +64,4 @@ public void execute_validIndexViewPerson_success() {
assertCommandSuccess(viewCommand, model, expectedMessage, expectedModel);
}
}

0 comments on commit d9745ff

Please sign in to comment.