Skip to content

Commit

Permalink
Add parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxunn committed Oct 21, 2023
1 parent 13da081 commit fc6916b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/seedu/address/logic/commands/ViewCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public CommandResult execute(Model model) throws CommandException {
logger.info("Client to View: " + personToView);
return new CommandResult(MESSAGE_SUCCESS);
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}

if (other == null || getClass() != other.getClass()) {
return false;
}

ViewCommand that = (ViewCommand) other;

return targetIndex.equals(that.targetIndex);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package seedu.address.logic.parser;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;

import org.junit.jupiter.api.Test;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.ViewCommand;
public class ViewCommandParserTest {
private ViewCommandParser parser = new ViewCommandParser();

@Test
public void parse_emptyArg_throwsParseException() {
assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE));
}
@Test
public void parse_validArgs_returnsViewCommand() {
ViewCommand expectedViewCommand = new ViewCommand(Index.fromOneBased(2));
assertParseSuccess(parser, "2", expectedViewCommand);
}

}

0 comments on commit fc6916b

Please sign in to comment.