From 3930ef2199488eb3e7fe927a555edbb0b8a018cb Mon Sep 17 00:00:00 2001 From: avrilmohh Date: Thu, 17 Oct 2024 01:38:33 +0800 Subject: [PATCH 1/2] Add test cases for equals and toString --- .../commands/MarkAssignmentCommandTest.java | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java b/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java index 888953c3757..db3994d520a 100644 --- a/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java @@ -1,10 +1,9 @@ package seedu.address.logic.commands; -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 org.junit.jupiter.api.Assertions.*; +import static seedu.address.logic.commands.CommandTestUtil.*; +import static seedu.address.logic.commands.CommandTestUtil.VALID_SCORE; +import static seedu.address.testutil.TypicalIndexes.*; import java.util.ArrayList; @@ -71,4 +70,39 @@ public void execute_invalidAssignmentIndex_markFailure() { String expectedMessage = Messages.MESSAGE_INVALID_ASSIGNMENT_INDEX; assertCommandFailure(markAssignmentCommand, model, expectedMessage); } + + @Test + public void equals() { + MarkAssignmentCommand markFirstCommand = new MarkAssignmentCommand(INDEX_FIRST_STUDENT, + INDEX_FIRST_ASSIGNMENT); + MarkAssignmentCommand markSecondCommand = new MarkAssignmentCommand(INDEX_SECOND_STUDENT, + INDEX_FIRST_ASSIGNMENT); + + // same object -> returns true + assertTrue(markFirstCommand.equals(markFirstCommand)); + + // same values -> returns true + MarkAssignmentCommand markFirstCommandCopy = new MarkAssignmentCommand(INDEX_FIRST_STUDENT, + INDEX_FIRST_ASSIGNMENT); + assertTrue(markFirstCommand.equals(markFirstCommandCopy)); + + // different types -> returns false + assertFalse(markFirstCommand.equals(1)); + + // null -> returns false + assertFalse(markFirstCommand.equals(null)); + + // different student -> returns false + assertFalse(markFirstCommand.equals(markSecondCommand)); + } + + @Test + public void toStringMethod() { + MarkAssignmentCommand markAssignmentCommand = new MarkAssignmentCommand(INDEX_FIRST_STUDENT, + INDEX_FIRST_ASSIGNMENT); + String expected = MarkAssignmentCommand.class.getCanonicalName() + "{studentIndex=" + INDEX_FIRST_STUDENT + + ", assignmentIndex=" + INDEX_FIRST_ASSIGNMENT + "}"; + assertEquals(expected, markAssignmentCommand.toString()); + } + } From bd8cd410b30e4a5aeef085a2058036da51ead4e6 Mon Sep 17 00:00:00 2001 From: avrilmohh Date: Thu, 17 Oct 2024 01:41:20 +0800 Subject: [PATCH 2/2] Fix checkstyle issue --- .../logic/commands/MarkAssignmentCommandTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java b/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java index db3994d520a..dcd707d35df 100644 --- a/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/MarkAssignmentCommandTest.java @@ -1,9 +1,13 @@ package seedu.address.logic.commands; -import static org.junit.jupiter.api.Assertions.*; -import static seedu.address.logic.commands.CommandTestUtil.*; -import static seedu.address.logic.commands.CommandTestUtil.VALID_SCORE; -import static seedu.address.testutil.TypicalIndexes.*; +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;