package seedu.todo.guitests;

import static org.junit.Assert.*;
import static seedu.todo.testutil.AssertUtil.assertSameDate;

import java.time.LocalDate;
import java.time.LocalDateTime;

import org.junit.Before;
import org.junit.Test;

import seedu.todo.commons.util.DateUtil;
import seedu.todo.guitests.guihandles.TaskListDateItemHandle;
import seedu.todo.guitests.guihandles.TaskListEventItemHandle;
import seedu.todo.guitests.guihandles.TaskListTaskItemHandle;
import seedu.todo.models.Task;
import seedu.todo.models.TodoListDB;

/**
 * @@author A0093907W
 */
public class UndoRedoCommandTest extends GuiTest {

    private final LocalDateTime oneDayFromNow = LocalDateTime.now().plusDays(1);
    private final String oneDayFromNowString = DateUtil.formatDate(oneDayFromNow);
    private final String oneDayFromNowIsoString = DateUtil.formatIsoDate(oneDayFromNow);
    private final LocalDateTime twoDaysFromNow = LocalDateTime.now().plusDays(2);
    private final String twoDaysFromNowString = DateUtil.formatDate(twoDaysFromNow);
    private final String twoDaysFromNowIsoString = DateUtil.formatIsoDate(twoDaysFromNow);
    
    String commandAdd1 = String.format("add task Buy KOI by \"%s 8pm\"", oneDayFromNowString);
    Task task1 = new Task();
    String commandAdd2 = String.format("add task Buy Milk by \"%s 9pm\"", twoDaysFromNowString);
    Task task2 = new Task();
    
    public UndoRedoCommandTest() {
        task1.setName("Buy KOI");
        task1.setCalendarDateTime(DateUtil.parseDateTime(String.format("%s 20:00:00", oneDayFromNowIsoString)));
        task2.setName("Buy Milk");
        task2.setDueDate(DateUtil.parseDateTime(String.format("%s 21:00:00", twoDaysFromNowIsoString)));
    }
    
    @Before
    public void resetDB() {
        TodoListDB db = TodoListDB.getInstance();
        db.destroyAllEvent();
        db.destroyAllTask();
    }
}

@@ -1867,10 +1867,601 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void undo_single() %7B%0A        console.runCommand(%22clear%22);%0A        assertTaskVisibleAfterCmd(commandAdd1, task1);%0A        assertTaskVisibleAfterCmd(commandAdd2, task2);%0A        assertTaskNotVisibleAfterCmd(%22undo%22, task2);%0A    %7D%0A    %0A    @Test%0A    public void undo_multiple() %7B%0A        console.runCommand(%22clear%22);%0A        assertTaskVisibleAfterCmd(commandAdd1, task1);%0A        assertTaskVisibleAfterCmd(commandAdd2, task2);%0A        assertTaskNotVisibleAfterCmd(%22undo 2%22, task1);%0A        assertTaskNotVisibleAfterCmd(%22list%22, task2); // A li'l hacky but oh well%0A    %7D%0A
 %7D%0A

Undo single and multiple