forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from avrilmohh/mark-assignment-parser-tests
Create mark assignment parser tests
- Loading branch information
Showing
2 changed files
with
91 additions
and
1 deletion.
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
91 changes: 91 additions & 0 deletions
91
src/test/java/seedu/address/logic/parser/MarkAssignmentCommandParserTest.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,91 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ASSIGNMENT_INDEX; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_STUDENT_INDEX; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_ASSIGNMENT; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_ASSIGNMENT; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.MarkAssignmentCommand; | ||
|
||
public class MarkAssignmentCommandParserTest { | ||
|
||
private final MarkAssignmentCommandParser parser = new MarkAssignmentCommandParser(); | ||
|
||
@Test | ||
public void parse_validArgs_returnsMarkAssignmentCommand() { | ||
String userInput = " " + PREFIX_STUDENT_INDEX + INDEX_FIRST_STUDENT.getOneBased() + " " | ||
+ PREFIX_ASSIGNMENT_INDEX + INDEX_FIRST_ASSIGNMENT.getOneBased(); | ||
assertParseSuccess(parser, userInput, new MarkAssignmentCommand(INDEX_FIRST_STUDENT, INDEX_FIRST_ASSIGNMENT)); | ||
} | ||
|
||
@Test | ||
public void parse_invalidArgs_throwsParseException() { | ||
assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
@Test | ||
public void parse_missingPrefixes_throwsParseException() { | ||
// Missing both prefixes | ||
String userInput = "1 1"; | ||
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
|
||
// Missing student prefix | ||
userInput = "1 " + PREFIX_ASSIGNMENT_INDEX + "1"; | ||
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
|
||
// Missing assignment prefix | ||
userInput = PREFIX_STUDENT_INDEX + "1"; | ||
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
@Test | ||
public void parse_duplicatePrefixes_throwsParseException() { | ||
// Duplicate student prefix | ||
String duplicateStudentInput = " " + PREFIX_STUDENT_INDEX + INDEX_FIRST_STUDENT.getOneBased() + " " | ||
+ PREFIX_STUDENT_INDEX + INDEX_SECOND_STUDENT + " " + PREFIX_ASSIGNMENT_INDEX + INDEX_FIRST_ASSIGNMENT; | ||
Prefix[] duplicatedStudentPrefixes = { PREFIX_STUDENT_INDEX }; | ||
assertParseFailure(parser, duplicateStudentInput, | ||
Messages.getErrorMessageForDuplicatePrefixes(duplicatedStudentPrefixes)); | ||
|
||
// Duplicate assignment prefix | ||
String duplicateAssignmentInput = " " + PREFIX_STUDENT_INDEX + INDEX_FIRST_STUDENT.getOneBased() + " " | ||
+ PREFIX_ASSIGNMENT_INDEX + INDEX_FIRST_ASSIGNMENT + " " | ||
+ PREFIX_ASSIGNMENT_INDEX + INDEX_SECOND_ASSIGNMENT; | ||
Prefix[] duplicatedAssignmentPrefixes = { PREFIX_ASSIGNMENT_INDEX }; | ||
assertParseFailure(parser, duplicateAssignmentInput, | ||
Messages.getErrorMessageForDuplicatePrefixes(duplicatedAssignmentPrefixes)); | ||
} | ||
|
||
@Test | ||
public void parse_nonNumericIndexes_throwsParseException() { | ||
// Non-numeric student index | ||
String userInput = PREFIX_STUDENT_INDEX + "a " + PREFIX_ASSIGNMENT_INDEX + "1"; | ||
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
|
||
// Non-numeric assignment index | ||
userInput = PREFIX_STUDENT_INDEX + "1 " + PREFIX_ASSIGNMENT_INDEX + "b"; | ||
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
@Test | ||
public void parse_emptyInput_throwsParseException() { | ||
// Empty input | ||
assertParseFailure(parser, "", String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
MarkAssignmentCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
} |