package guitests;

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

//@@author A0125097A
public class UndoCommandTest extends AddressBookGuiTest {

    @Test
    public void undo_addCommand() {
        TestActivity[] currentList = td.getTypicalPersons();
        TestActivity activityToAdd = td.findHoon;
        assertUndoAddResult(activityToAdd,currentList);
        
    }
    
    @Test
    public void undo_deleteCommand() {
        TestActivity[] currentList = td.getTypicalPersons();
        int index = 2;
        assertUndoDeleteResult(index,currentList);
    }
    
    @Test
    public void undo_doneCommand() {
        TestActivity[] currentList = td.getTypicalPersons();
        int index = 4;
        assertUndoDoneResult(index,currentList);
    }

    
    
    
    private void assertUndoAddResult(TestActivity activity,TestActivity... currentList){
        commandBox.runCommand(activity.getAddCommand());
        commandBox.runCommand("undo");
        assertResultMessage(String.format("Undo: Adding of new task: %1$s",activity.getAsText()));
        assertTrue(activityListPanel.isListMatching(currentList));
        
    }
    
    private void assertUndoDeleteResult(int index,TestActivity... currentList){
        TestActivity activityToDelete = currentList[index-1];
        
        commandBox.runCommand("delete " + index);
        commandBox.runCommand("undo");
        assertResultMessage(String.format("Undo: Deleting task: %1$s",activityToDelete.getAsText()));
        assertTrue(activityListPanel.isListMatching(currentList));
    }
    
    private void assertUndoDoneResult(int index,TestActivity... currentList){
        TestActivity activityToDone = currentList[index-1];
        
        commandBox.runCommand("done " + index);
        commandBox.runCommand("undo");
        assertResultMessage(String.format("Undo: Marked task as Completed: %1$s",activityToDone.getAsText()));
        assertTrue(activityListPanel.isListMatching(currentList));
        
    }
    
}

@@ -113,73 +113,9 @@
 til.
-TestActivity;%0Aimport seedu.address.testutil.TypicalTestActivities
+*
 ;%0Aim
@@ -855,26 +855,1161 @@
  %7D%0A%0A    
-%0A    %0A    
+@Test%0A    public void undo_editCommand() %7B%0A        TestActivity%5B%5D currentList = td.getTypicalPersons();%0A        int index = 1;%0A        String newName = %22new name%22;%0A        String newReminder = %2229-12-2021 2200%22;%0A        TestActivity activityBeforeEdit = new TestActivity(currentList%5Bindex-1%5D);%0A        TestActivity activityAfterEdit = new TestActivity(currentList%5Bindex-1%5D);%0A        activityAfterEdit.setName(newName);%0A        activityAfterEdit.setReminder(newReminder);%0A        String editCommand = %22edit %22 + index + %22 n/%22 + newName + %22 r/%22 + newReminder;%0A        assertUndoEditResult(editCommand,activityBeforeEdit,activityAfterEdit,currentList);%0A    %7D%0A    %0A    %0A    private void assertUndoEditResult(String command, TestActivity activityAfterUndo, TestActivity activityBeforeUndo, TestActivity%5B%5D currentList) %7B%0A        commandBox.runCommand(command);%0A        commandBox.runCommand(%22undo%22); %0A        assertResultMessage(String.format(%22Undo: Editting task from: %251$s%5Cnto: %252$s%22,%0A                activityAfterUndo.getAsText(),activityBeforeUndo.getAsText()));%0A        assertTrue(activityListPanel.isListMatching(currentList));%0A  %0A        %0A    %7D%0A
 %0A    pri

Add Edit test for UndoCommandTest