Skip to content

Commit

Permalink
Merge pull request #98 from avrilmohh/unmark-assignment-tests
Browse files Browse the repository at this point in the history
Add unmark assignment tests for equals and toString
  • Loading branch information
avrilmohh authored Oct 16, 2024
2 parents e7bfecb + f784373 commit 3a2a658
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
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 static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT;

import java.util.ArrayList;

Expand Down Expand Up @@ -70,4 +73,38 @@ public void execute_invalidAssignmentIndex_throwsCommandException() {
assertCommandFailure(unmarkAssignmentCommand, model, Messages.MESSAGE_INVALID_ASSIGNMENT_INDEX);
}

@Test
public void equals() {
UnmarkAssignmentCommand unmarkFirstCommand = new UnmarkAssignmentCommand(INDEX_FIRST_STUDENT,
INDEX_FIRST_ASSIGNMENT);
UnmarkAssignmentCommand unmarkSecondCommand = new UnmarkAssignmentCommand(INDEX_SECOND_STUDENT,
INDEX_FIRST_ASSIGNMENT);

// same object -> returns true
assertTrue(unmarkFirstCommand.equals(unmarkFirstCommand));

// same values -> returns true
UnmarkAssignmentCommand unmarkFirstCommandCopy = new UnmarkAssignmentCommand(INDEX_FIRST_STUDENT,
INDEX_FIRST_ASSIGNMENT);
assertTrue(unmarkFirstCommand.equals(unmarkFirstCommandCopy));

// different types -> returns false
assertFalse(unmarkFirstCommand.equals(1));

// null -> returns false
assertFalse(unmarkFirstCommand.equals(null));

// different student -> returns false
assertFalse(unmarkFirstCommand.equals(unmarkSecondCommand));
}

@Test
public void toStringMethod() {
UnmarkAssignmentCommand unmarkAssignmentCommand = new UnmarkAssignmentCommand(INDEX_FIRST_STUDENT,
INDEX_FIRST_ASSIGNMENT);
String expected = UnmarkAssignmentCommand.class.getCanonicalName() + "{studentIndex=" + INDEX_FIRST_STUDENT
+ ", assignmentIndex=" + INDEX_FIRST_ASSIGNMENT + "}";
assertEquals(expected, unmarkAssignmentCommand.toString());
}

}

0 comments on commit 3a2a658

Please sign in to comment.