package guitests;

import guitests.guihandles.TaskCardHandle;
import org.junit.Test;

import seedu.task.commons.core.Messages;
import seedu.task.logic.commands.AddCommand;
import seedu.task.model.task.Task;
import seedu.task.model.task.UniqueTaskList;
import seedu.task.testutil.TestTask;
import seedu.task.testutil.TestUtil;
import seedu.task.testutil.TypicalTestTasks;

import static org.junit.Assert.assertTrue;

public class AddCommandTest extends TaskBookGuiTest {
    //@@author A0138301U
    
    @Test
    public void add() {
        //add one task
        TestTask taskToAdd = TypicalTestTasks.play;
        TestTask[] currentList = td.getTypicalTasks();
        currentList = TestUtil.addTasksToList(currentList, taskToAdd);
        //assertAddSuccess(taskToAdd, currentList); 

        //add task with dates clashing with other tasks
        taskToAdd = TypicalTestTasks.coding;
        commandBox.runCommand(taskToAdd.getAddCommand());
        //assertResultMessage(String.format(Task.DATE_CLASH_MESSAGE, "code cs2103", "Fri Nov 04 17:50:00 SGT 2016", "Fri Nov 04 17:50:00 SGT 2016"));

        //add to empty list
        commandBox.runCommand("clear");
        assertAddSuccess(td.play); 

        //invalid command
        commandBox.runCommand("adds get a massage");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
        //@@author
    }

    private void assertAddSuccess(TestTask taskToAdd, TestTask... currentList) {
        commandBox.runCommand(taskToAdd.getAddCommand());

        //confirm the new card contains the right data
        TaskCardHandle addedCard = taskListPanel.navigateToTask(taskToAdd.getName().fullName);
        assertMatching(taskToAdd, addedCard);

        //confirm the list now contains all previous tasks plus the new task
        TestTask[] expectedList = TestUtil.addTasksToList(currentList, taskToAdd);
        assertTrue(taskListPanel.isListMatching(expectedList));
    }

}

@@ -731,371 +731,8 @@
 dd);
-%0A        //assertAddSuccess(taskToAdd, currentList); %0A%0A        //add task with dates clashing with other tasks%0A        taskToAdd = TypicalTestTasks.coding;%0A        commandBox.runCommand(taskToAdd.getAddCommand());%0A        //assertResultMessage(String.format(Task.DATE_CLASH_MESSAGE, %22code cs2103%22, %22Fri Nov 04 17:50:00 SGT 2016%22, %22Fri Nov 04 17:50:00 SGT 2016%22));
 %0A%0A  

clean up