//@@author Matilda_yxx A0147996E
package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import guitests.guihandles.TaskCardHandle;
import seedu.address.commons.core.Messages;
import seedu.address.logic.commands.AddCommand;
import seedu.address.testutil.TestTask;
import seedu.address.testutil.TestUtil;

public class AddCommandTest extends TaskManagerGuiTest {

    @Test
    public void add() {
        //add task by name only
    		TestTask[] currentList = td.getTypicalTasks();
        TestTask taskToAdd = td.assignment;
        assertAddSuccess(taskToAdd, currentList);
        currentList = TestUtil.addTasksToList(currentList, taskToAdd);

        //add another task
        taskToAdd = td.date;
        assertAddSuccess(taskToAdd, currentList);
        currentList = TestUtil.addTasksToList(currentList, taskToAdd);

        //add duplicate task
        commandBox.runCommand(td.date.getAddCommand());
        assertResultMessage(AddCommand.MESSAGE_DUPLICATE_TASK);
        assertTrue(taskListPanel.isListMatching(currentList));

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

        //unknown command
        commandBox.runCommand("adds homework");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
       
        //invalid command, task must have a name
        commandBox.runCommand("add p/important");
        assertResultMessage(Messages.MESSAGE_INVALID_COMMAND_FORMAT);
      //invalid command, name should be the first field entered
        commandBox.runCommand("add p/important homework");
        assertResultMessage(Messages.MESSAGE_INVALID_COMMAND_FORMAT);
    }

    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 persons plus the new person
        TestTask[] expectedList = TestUtil.addTasksToList(currentList, taskToAdd);
        assertTrue(taskListPanel.isListMatching(expectedList));
    }
}

@@ -458,17 +458,16 @@
 ly%0A    %09
-%09
 TestTask
@@ -1302,23 +1302,16 @@
 MMAND);%0A
-       
 %0A       
@@ -1422,32 +1422,46 @@
 rtResultMessage(
+String.format(
 Messages.MESSAGE
@@ -1483,25 +1483,55 @@
 D_FORMAT
+, AddCommand.MESSAGE_USAGE)
 );%0A
+%0A 
       
+ 
 //invali
@@ -1659,32 +1659,46 @@
 rtResultMessage(
+String.format(
 Messages.MESSAGE
@@ -1720,16 +1720,43 @@
 D_FORMAT
+, AddCommand.MESSAGE_USAGE)
 );%0A    %7D

Modify testcases for AddCommandTest