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;

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;
        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 assertUndoResult(String command,TestActivity... currentList){
        commandBox.runCommand(command);
        commandBox.runCommand("undo");
        assertTrue(activityListPanel.isListMatching(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));
        
    }
    
    
}

@@ -634,17 +634,17 @@
     int 
-I
+i
 ndex = 2
@@ -657,71 +657,161 @@
     
-TestActivity activityToDelete = currentList%5BIndex-1%5D ;%0A        
+assertUndoDeleteResult(index,currentList);%0A    %7D%0A    %0A    %0A%0A    %0A    private void assertUndoAddResult(TestActivity activity,TestActivity... currentList)%7B
 %0A   
@@ -841,25 +841,32 @@
 and(
-%22delete %22 + Index
+activity.getAddCommand()
 );%0A 
@@ -956,16 +956,21 @@
 do: 
-Deleting
+Adding of new
  tas
@@ -990,16 +990,8 @@
 vity
-ToDelete
 .get
@@ -1073,25 +1073,24 @@
 ));%0A        
- 
 %0A    %7D%0A    %0A
@@ -1089,21 +1089,16 @@
  %7D%0A    %0A
-    %0A
     priv
@@ -1120,29 +1120,30 @@
 Undo
+Delete
 Result(
-String command
+int index
 ,Tes
@@ -1199,23 +1199,33 @@
 Command(
-command
+%22delete %22 + index
 );%0A     
@@ -1270,270 +1270,60 @@
     
-assertTrue(activityListPanel.isListMatching(currentList));%0A        %0A    %7D%0A    %0A    private void assertUndoAddResult(TestActivity activity,TestActivity... currentList)%7B%0A        commandBox.runCommand(activity.getAddCommand());%0A        commandBox.runCommand(%22undo%22)
+TestActivity activityToDelete = currentList%5Bindex-1%5D
 ;%0A  
@@ -1365,37 +1365,32 @@
 rmat(%22Undo: 
-Adding of new
+Deleting
  task: %251$s%22
@@ -1390,32 +1390,40 @@
 : %251$s%22,activity
+ToDelete
 .getAsText()));%0A
@@ -1509,15 +1509,10 @@
  %7D%0A    %0A
-    %0A
 %7D%0A

Refactor UncoCommandTest