From 835babf29835295865edff866ab52b9357a68c59 Mon Sep 17 00:00:00 2001 From: Kieron Seven Lee Date: Sat, 14 Oct 2023 11:54:05 +0800 Subject: [PATCH] Add equals test for load command --- .../logic/commands/LoadCommandTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/java/seedu/address/logic/commands/LoadCommandTest.java b/src/test/java/seedu/address/logic/commands/LoadCommandTest.java index 8e35237db0b..49b2e0203c1 100644 --- a/src/test/java/seedu/address/logic/commands/LoadCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/LoadCommandTest.java @@ -1,5 +1,7 @@ package seedu.address.logic.commands; +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.logic.commands.LoadCommand.MESSAGE_FILE_CANNOT_LOAD; @@ -70,4 +72,32 @@ public void loadAddressBook(Model expectedModel, String fileName, Path filePath) expectedModel.setAddressBookFilePath(filePath); expectedModel.setAddressBook(tempData); } + + @Test + public void equals() { + String firstFileName = "validAddressBook"; + Path firstFilePath = TEST_DATA_FOLDER.resolve(firstFileName + ".json"); + + String secondFileName = "addressBook"; + Path secondFilePath = TEST_DATA_FOLDER.resolve(secondFileName + ".json"); + + LoadCommand loadFirstCommand = new LoadCommand(firstFileName, firstFilePath); + LoadCommand loadSecondCommand = new LoadCommand(secondFileName, secondFilePath); + + // same object -> returns true + assertTrue(loadFirstCommand.equals(loadFirstCommand)); + + // same values -> returns true + LoadCommand loadFirstCommandCopy = new LoadCommand(firstFileName, firstFilePath); + assertTrue(loadFirstCommand.equals(loadFirstCommandCopy)); + + // different types -> returns false + assertFalse(loadFirstCommand.equals(1)); + + // null -> returns false + assertFalse(loadFirstCommand.equals(null)); + + // different person -> returns false + assertFalse(loadFirstCommand.equals(loadSecondCommand)); + } }