package guitests;

import org.junit.Test;

import seedu.tasklist.commons.exceptions.IllegalValueException;
import seedu.tasklist.logic.commands.UndoCommand;
import seedu.tasklist.model.task.EndTime;
import seedu.tasklist.model.task.Priority;
import seedu.tasklist.model.task.StartTime;
import seedu.tasklist.model.task.TaskDetails;
import seedu.tasklist.testutil.TestTask;
import seedu.tasklist.testutil.TypicalTestTasks;

public class UndoCommandTest extends TaskListGuiTest {
    
    @Test
    public void undoOneChange() throws IllegalValueException {
        TestTask[] currentList = td.getTypicalTasks();
        //undo a change that was never made
        commandBox.runCommand("update 20 Buy eggs");
        commandBox.runCommand("undo");
        assertResultMessage(UndoCommand.MESSAGE_FAILURE);
        //undo one change
        commandBox.runCommand("update 1 Attend yoga session from 2pm to 4pm p/high");
        TypicalTestTasks.task1.setTaskDetails(new TaskDetails("Attend yoga session"));
        TypicalTestTasks.task1.setStartTime(new StartTime("2pm"));
        TypicalTestTasks.task1.setEndTime(new EndTime("4pm"));
        TypicalTestTasks.task1.setPriority(new Priority("high")); 
        commandBox.runCommand("undo");
        TypicalTestTasks.task1.setTaskDetails(new TaskDetails("Buy eggs"));
        TypicalTestTasks.task1.setStartTime(new StartTime("5pm"));
        TypicalTestTasks.task1.setEndTime(new EndTime("-"));
        TypicalTestTasks.task1.setPriority(new Priority("high"));
        assertResultMessage(UndoCommand.MESSAGE_SUCCESS);
    }
    
    @Test
    public void undoTwoChanges() throws IllegalValueException {
        TestTask[] currentList = td.getTypicalTasks();
        //undo a change that was never made
        commandBox.runCommand("update 20 Buy eggs");
        commandBox.runCommand("undo");
        assertResultMessage(UndoCommand.MESSAGE_FAILURE);
        //undo one change
        commandBox.runCommand("update 1 Attend yoga session from 2pm to 4pm p/high");
        TypicalTestTasks.task1.setTaskDetails(new TaskDetails("Attend yoga session"));
        TypicalTestTasks.task1.setStartTime(new StartTime("2pm"));
        TypicalTestTasks.task1.setEndTime(new EndTime("4pm"));
        TypicalTestTasks.task1.setPriority(new Priority("high")); 
        commandBox.runCommand("delete 2");
        commandBox.runCommand("undo");
        assertResultMessage(UndoCommand.MESSAGE_SUCCESS);
        commandBox.runCommand("undo");
        TypicalTestTasks.task1.setTaskDetails(new TaskDetails("Buy eggs"));
        TypicalTestTasks.task1.setStartTime(new StartTime("5pm"));
        TypicalTestTasks.task1.setEndTime(new EndTime("-"));
        TypicalTestTasks.task1.setPriority(new Priority("high"));
        assertResultMessage(UndoCommand.MESSAGE_SUCCESS);
    }
    
    @Test
    public void undoThreeChanges() {
        //TODO
    }
    
    @Test
    public void undoAddTest() {
        //TODO
    }
    
    @Test
    public void undoDeleteTest() {
        //TODO
    }
    
    @Test
    public void undoUpdateTest() {
        //TODO
    }
    
    @Test
    public void undoDoneTest() {
        //TODO
    }
    
    @Test
    public void undoClearTest() {
        //TODO
    }
    
    @Test
    public void undoSetstorageTest() {
        //TODO
    }
    
}
@@ -1423,33 +1423,32 @@
 me(new EndTime(%22
--
 %22));%0A        Typ
@@ -1905,34 +1905,35 @@
      //undo 
-one
+two
  change
+s
 %0A        com
@@ -2672,9 +2672,8 @@
 me(%22
--
 %22));
@@ -2805,76 +2805,1329 @@
     
-%7D%0A    %0A    @Test%0A    public void undoThreeChanges() %7B%0A        //TODO
+    commandBox.runCommand(%22undo%22);%0A        assertResultMessage(UndoCommand.MESSAGE_FAILURE);%0A    %7D%0A    %0A    @Test%0A    public void undoThreeChanges() throws IllegalValueException %7B%0A        //undo three changes%0A        commandBox.runCommand(%22update 1 Attend yoga session from 2pm to 4pm p/high%22);%0A        TypicalTestTasks.task1.setTaskDetails(new TaskDetails(%22Attend yoga session%22));%0A        TypicalTestTasks.task1.setStartTime(new StartTime(%222pm%22));%0A        TypicalTestTasks.task1.setEndTime(new EndTime(%224pm%22));%0A        TypicalTestTasks.task1.setPriority(new Priority(%22high%22)); %0A        commandBox.runCommand(%22delete 2%22);%0A        commandBox.runCommand(%22delete 2%22);%0A        commandBox.runCommand(%22undo%22);%0A        assertResultMessage(UndoCommand.MESSAGE_SUCCESS);%0A        commandBox.runCommand(%22undo%22);%0A        assertResultMessage(UndoCommand.MESSAGE_SUCCESS);%0A        commandBox.runCommand(%22undo%22);%0A        TypicalTestTasks.task1.setTaskDetails(new TaskDetails(%22Buy eggs%22));%0A        TypicalTestTasks.task1.setStartTime(new StartTime(%225pm%22));%0A        TypicalTestTasks.task1.setEndTime(new EndTime(%22%22));%0A        TypicalTestTasks.task1.setPriority(new Priority(%22high%22));%0A        assertResultMessage(UndoCommand.MESSAGE_SUCCESS);%0A        commandBox.runCommand(%22undo%22);%0A        assertResultMessage(UndoCommand.MESSAGE_FAILURE);
 %0A   

Add test cases for Undo Command