Skip to content

Commit

Permalink
Add DeleteCourseCommandParserTest and update test files
Browse files Browse the repository at this point in the history
  • Loading branch information
gongg21 committed Nov 14, 2023
1 parent 1397ba5 commit 9ee1c4d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,17 @@

import seedu.codesphere.logic.commands.DeleteCommand;

/**
* 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 DeleteCommandParserTest {

private DeleteCommandParser parser = new DeleteCommandParser();

@Test
public void parse_validArgs_returnsDeleteCommand() {
public void parse_validIndex_returnsDeleteCommand() {
assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_STUDENT));
}

@Test
public void parse_invalidArgs_throwsParseException() {
public void parse_invalidIndex_throwsParseException() {
assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package seedu.codesphere.logic.parser;

import static seedu.codesphere.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.codesphere.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.codesphere.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.codesphere.testutil.TypicalIndexes.INDEX_FIRST_STUDENT;

import org.junit.jupiter.api.Test;

import seedu.codesphere.logic.commands.DeleteCourseCommand;

public class DeleteCourseCommandParserTest {

private DeleteCourseCommandParser parser = new DeleteCourseCommandParser();

@Test
public void parse_validIndex_returnsDeleteCourseCommand() {
assertParseSuccess(parser, "1", new DeleteCourseCommand(INDEX_FIRST_STUDENT));
}

@Test
public void parse_invalidIndex_throwsParseException() {
assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCourseCommand.MESSAGE_USAGE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,17 @@

import seedu.codesphere.logic.commands.SelectCommand;

/**
* As we are only doing white-box testing, our test cases do not cover path variations
* outside of the SelectCommand code. For example, inputs "1" and "1 abc" take the
* same path through the SelectCommand, 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 SelectCommandParserTest {

private SelectCommandParser parser = new SelectCommandParser();

@Test
public void parse_validArgs_returnsSelectCommand() {
public void parse_validIndex_returnsSelectCommand() {
assertParseSuccess(parser, "1", new SelectCommand(INDEX_FIRST_STUDENT));
}

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

0 comments on commit 9ee1c4d

Please sign in to comment.