Skip to content

Commit

Permalink
Merge pull request #186 from feifeiraindrops/test-list
Browse files Browse the repository at this point in the history
Add test to listAll
  • Loading branch information
seraphimstreets authored Nov 13, 2023
2 parents fc81007 + fe80e5d commit 81d31c0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/seedu/modulight/logic/commands/ListAllCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,17 @@ public CommandResult execute(Model model) {
model.updateFilteredStudentScoreList(PREDICATE_SHOW_ALL_STUDENT_SCORES);
return new CommandResult(MESSAGE_SUCCESS);
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof ListAllCommand)) {
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package seedu.modulight.logic.commands;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.modulight.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.modulight.testutil.TypicalStudents.getTypicalComponentBook;
import static seedu.modulight.testutil.TypicalStudents.getTypicalScoreBook;
import static seedu.modulight.testutil.TypicalStudents.getTypicalStudentBook;

import org.junit.jupiter.api.Test;

import seedu.modulight.model.Model;
import seedu.modulight.model.ModelManager;
import seedu.modulight.model.UserPrefs;

public class ListAllCommandTest {
private Model model = new ModelManager(getTypicalStudentBook(), getTypicalScoreBook(), getTypicalComponentBook(),
new UserPrefs());
private Model expectedModel = new ModelManager(getTypicalStudentBook(), getTypicalScoreBook(),
getTypicalComponentBook(), new UserPrefs());
@Test
public void excute_nonFiltered_success() {
ListAllCommand command = new ListAllCommand();
String expectedMessage = "Listed all students, student scores and graded components";
assertCommandSuccess(command, model, expectedMessage, expectedModel);
}

@Test
public void excute_filtered_success() {
ListAllCommand command = new ListAllCommand();
model.updateFilteredStudentList(Model.PREDICATE_SHOW_NO_STUDENTS);
model.updateFilteredGradedComponentList(Model.PREDICATE_SHOW_NO_COMPONENT);
String expectedMessage = "Listed all students, student scores and graded components";
assertCommandSuccess(command, model, expectedMessage, expectedModel);
}

@Test
public void equals() {

ListAllCommand firstCommand = new ListAllCommand();
ListAllCommand secondCommand = new ListAllCommand();

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

// same type -> returns true
assertTrue(firstCommand.equals(secondCommand));

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

// null -> returns false
assertFalse(firstCommand.equals(null));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package seedu.modulight.logic.parser;

import static seedu.modulight.logic.parser.CommandParserTestUtil.assertParseSuccess;

import org.junit.jupiter.api.Test;

import seedu.modulight.logic.commands.ListAllCommand;

public class ListAllCommandParserTest {
private ListAllCommandParser parser = new ListAllCommandParser();
@Test
public void parse_noInput_success() {
ListAllCommand expectedCommand = new ListAllCommand();
assertParseSuccess(parser, " ", expectedCommand);
}

@Test
public void parse_withInput_success() {
ListAllCommand expectedCommand = new ListAllCommand();
assertParseSuccess(parser, " t/t01 ", expectedCommand);
}
}

0 comments on commit 81d31c0

Please sign in to comment.