Skip to content

Commit

Permalink
Add swaproom command parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sushinoya committed Oct 25, 2017
1 parent d788a4d commit 3066617
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package seedu.room.logic.parser;

import static seedu.room.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.room.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.room.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.room.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.room.testutil.TypicalIndexes.INDEX_SECOND_PERSON;

import org.junit.Test;

import seedu.room.logic.commands.SwaproomCommand;

/**
* As we are only doing white-box testing, our test cases do not cover path variations
* outside of the DeleteCommand code. For example, inputs "1" and "1 abc" take the
* same path through the DeleteCommand, and therefore we test only one of them.
* The path variation for those two cases occur inside the ParserUtil, and
* therefore should be covered by the ParserUtilTest.
*/
public class SwaproomCommandParserTest {

private SwaproomCommandParser parser = new SwaproomCommandParser();

@Test
public void parse_validArgs_returnsSwapCommand() {
assertParseSuccess(parser, " 1 2", new SwaproomCommand(INDEX_FIRST_PERSON, INDEX_SECOND_PERSON));
}

@Test
public void parse_invalidArgs_throwsParseException() {
assertParseFailure(parser, " a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, SwaproomCommand.MESSAGE_USAGE));
}

@Test
public void parse_invalidNumArgs_throwsParseException() {
assertParseFailure(parser, " 1 3 4", String.format(MESSAGE_INVALID_COMMAND_FORMAT,
SwaproomCommand.MESSAGE_USAGE));
}
}

0 comments on commit 3066617

Please sign in to comment.