Skip to content

Commit

Permalink
Add Edit test for UndoCommandTest
Browse files Browse the repository at this point in the history
  • Loading branch information
aloisiusStephen committed Nov 2, 2016
1 parent 8fa337d commit 4487ba0
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/test/java/guitests/UndoCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import org.junit.Test;
import seedu.address.commons.core.Messages;
import seedu.address.testutil.TestActivity;
import seedu.address.testutil.TypicalTestActivities;
import seedu.address.testutil.*;
import static org.junit.Assert.assertTrue;

//@@author A0125097A
Expand Down Expand Up @@ -31,9 +30,31 @@ public void undo_doneCommand() {
assertUndoDoneResult(index,currentList);
}

@Test
public void undo_editCommand() {
TestActivity[] currentList = td.getTypicalPersons();
int index = 1;
String newName = "new name";
String newReminder = "29-12-2021 2200";
TestActivity activityBeforeEdit = new TestActivity(currentList[index-1]);
TestActivity activityAfterEdit = new TestActivity(currentList[index-1]);
activityAfterEdit.setName(newName);
activityAfterEdit.setReminder(newReminder);
String editCommand = "edit " + index + " n/" + newName + " r/" + newReminder;
assertUndoEditResult(editCommand,activityBeforeEdit,activityAfterEdit,currentList);
}



private void assertUndoEditResult(String command, TestActivity activityAfterUndo, TestActivity activityBeforeUndo, TestActivity[] currentList) {
commandBox.runCommand(command);
commandBox.runCommand("undo");
assertResultMessage(String.format("Undo: Editting task from: %1$s\nto: %2$s",
activityAfterUndo.getAsText(),activityBeforeUndo.getAsText()));
assertTrue(activityListPanel.isListMatching(currentList));


}

private void assertUndoAddResult(TestActivity activity,TestActivity... currentList){
commandBox.runCommand(activity.getAddCommand());
commandBox.runCommand("undo");
Expand Down

0 comments on commit 4487ba0

Please sign in to comment.