Skip to content

Commit

Permalink
Add equals test for load command
Browse files Browse the repository at this point in the history
  • Loading branch information
Cikguseven committed Oct 14, 2023
1 parent 6911b2e commit 835babf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/java/seedu/address/logic/commands/LoadCommandTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 835babf

Please sign in to comment.