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 #93 from avrilmohh/unmark-assignment-tests
Create test cases for unmark assignment
- Loading branch information
Showing
2 changed files
with
76 additions
and
12 deletions.
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
73 changes: 73 additions & 0 deletions
73
src/test/java/seedu/address/logic/commands/UnmarkAssignmentCommandTest.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,73 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_ASSIGNMENT; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.model.AddressBook; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.assignment.Assignment; | ||
import seedu.address.model.student.Student; | ||
import seedu.address.testutil.AssignmentBuilder; | ||
import seedu.address.testutil.StudentBuilder; | ||
|
||
public class UnmarkAssignmentCommandTest { | ||
|
||
private Model model = new ModelManager(new AddressBook(), new UserPrefs()); | ||
|
||
@Test | ||
public void execute_validStudentAndAssignmentIndex_unmarkSuccessful() { | ||
Assignment assignment = new AssignmentBuilder() | ||
.withHasSubmitted(true) | ||
.build(); | ||
Student student = new StudentBuilder().withAssignments(new ArrayList<>()).build().addAssignment(assignment); | ||
model.addStudent(student); | ||
UnmarkAssignmentCommand unmarkAssignmentCommand = new UnmarkAssignmentCommand( | ||
INDEX_FIRST_STUDENT, INDEX_FIRST_ASSIGNMENT); | ||
String expectedMessage = String.format(UnmarkAssignmentCommand.MESSAGE_UNMARK_SUCCESS, | ||
"Math Homework", student.getName().fullName); | ||
Model expectedModel = new ModelManager(new AddressBook(), model.getUserPrefs()); | ||
Assignment expectedAssignment = new AssignmentBuilder() | ||
.build(); | ||
Student expectedStudent = new StudentBuilder().build().addAssignment(expectedAssignment); | ||
expectedModel.addStudent(expectedStudent); | ||
assertCommandSuccess(unmarkAssignmentCommand, model, expectedMessage, expectedModel); | ||
assertEquals(false, student.getAssignmentList().get(INDEX_FIRST_ASSIGNMENT.getZeroBased()).getHasSubmitted()); | ||
assertEquals(0, student.getAssignmentList().get(INDEX_FIRST_ASSIGNMENT.getZeroBased()).getScore()); | ||
} | ||
|
||
@Test | ||
public void execute_invalidStudentIndex_throwsCommandException() { | ||
Assignment assignment = new AssignmentBuilder() | ||
.withHasSubmitted(true) | ||
.build(); | ||
Student student = new StudentBuilder().withAssignments(new ArrayList<>()).build().addAssignment(assignment); | ||
model.addStudent(student); | ||
UnmarkAssignmentCommand unmarkAssignmentCommand = new UnmarkAssignmentCommand( | ||
Index.fromOneBased(2), INDEX_FIRST_ASSIGNMENT); | ||
assertCommandFailure(unmarkAssignmentCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); | ||
} | ||
|
||
@Test | ||
public void execute_invalidAssignmentIndex_throwsCommandException() { | ||
Assignment assignment = new AssignmentBuilder() | ||
.withHasSubmitted(true) | ||
.build(); | ||
Student student = new StudentBuilder().withAssignments(new ArrayList<>()).build().addAssignment(assignment); | ||
model.addStudent(student); | ||
UnmarkAssignmentCommand unmarkAssignmentCommand = new UnmarkAssignmentCommand( | ||
INDEX_FIRST_STUDENT, Index.fromOneBased(2)); | ||
assertCommandFailure(unmarkAssignmentCommand, model, Messages.MESSAGE_INVALID_ASSIGNMENT_INDEX); | ||
} | ||
|
||
} |