Skip to content

Commit

Permalink
Add assertResultMessage and delete unused libraries in test
Browse files Browse the repository at this point in the history
  • Loading branch information
SukiTsang committed Oct 18, 2016
1 parent d960293 commit e78947d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/test/java/guitests/PinCommandTest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package guitests;

import guitests.guihandles.TaskCardHandle;
import static org.junit.Assert.assertTrue;
import static seedu.task.logic.commands.PinCommand.MESSAGE_PIN_TASK_SUCCESS;

import org.junit.Test;

import seedu.task.commons.core.Messages;
import seedu.task.commons.exceptions.IllegalValueException;
import seedu.task.logic.commands.UpdateCommand;
import seedu.task.model.tag.Tag;
import seedu.task.logic.commands.PinCommand;
import seedu.task.model.task.*;
import seedu.task.testutil.TestTask;
import seedu.task.testutil.TestUtil;

public class PinCommandTest extends TaskManagerGuiTest{
@Test
Expand All @@ -21,30 +18,35 @@ public void pin() throws IllegalValueException {
int targetIndex =1;

//invalid index
commandBox.runCommand("pin " + currentList.length + 1);
commandBox.runCommand("pin " + (currentList.length + 1));
assertResultMessage(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);

//pin the first task
commandBox.runCommand("pin "+targetIndex);
ReadOnlyTask newTask = taskListPanel.getTask(targetIndex - 1);
assertTrue(newTask.getImportance());
//confirm the result message is correct
assertResultMessage(String.format(MESSAGE_PIN_TASK_SUCCESS, newTask));


//pin another task
targetIndex=3;
commandBox.runCommand("pin "+targetIndex);
ReadOnlyTask otherTask = taskListPanel.getTask(targetIndex - 1);
assertTrue(otherTask.getImportance());
assertResultMessage(String.format(MESSAGE_PIN_TASK_SUCCESS, otherTask));


//pin the last task
targetIndex = currentList.length;
commandBox.runCommand("pin "+targetIndex);
newTask=taskListPanel.getTask(targetIndex - 1);
assertTrue(newTask.getImportance());
assertResultMessage(String.format(MESSAGE_PIN_TASK_SUCCESS, newTask));

//pin at an empty list
commandBox.runCommand("clear");
commandBox.runCommand("pin " + currentList.length + 1);
commandBox.runCommand("pin " + (currentList.length + 1));
assertResultMessage(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);

}
Expand Down

0 comments on commit e78947d

Please sign in to comment.