package guitests;

import static org.junit.Assert.assertTrue;
import static seedu.ezdo.logic.commands.KillCommand.MESSAGE_KILL_TASK_SUCCESS;

import org.junit.Test;

import seedu.ezdo.testutil.TestTask;
import seedu.ezdo.testutil.TestUtil;

public class KillCommandTest extends EzDoGuiTest {

    @Test
    public void kill() {

        //delete the first in the list
        TestTask[] currentList = td.getTypicalTasks();
        int targetIndex = 1;
        assertKillSuccess(targetIndex, currentList);

        //delete the last in the list
        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);
        targetIndex = currentList.length;
        assertKillSuccess(targetIndex, currentList);

        //delete from the middle of the list
        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);
        targetIndex = currentList.length / 2;
        assertKillSuccess(targetIndex, currentList);

        //invalid index
        commandBox.runCommand("kill " + currentList.length + 1);
        assertResultMessage("The task index provided is invalid");

    }

    /**
     * Runs the kill command to delete the task at specified index and confirms the result is correct.
     * @param targetIndexOneIndexed e.g. index 1 to delete the first task in the list,
     * @param currentList A copy of the current list of tasks (before deletion).
     */
    private void assertKillSuccess(int targetIndexOneIndexed, final TestTask[] currentList) {
        TestTask taskToKill = currentList[targetIndexOneIndexed - 1]; // -1 as array uses zero indexing
        TestTask[] expectedRemainder = TestUtil.removeTaskFromList(currentList, targetIndexOneIndexed);

        commandBox.runCommand("kill " + targetIndexOneIndexed);

        //confirm the list now contains all previous tasks except the deleted task
        assertTrue(taskListPanel.isListMatching(expectedRemainder));

        //confirm the result message is correct
        assertResultMessage(String.format(MESSAGE_KILL_TASK_SUCCESS, taskToKill));
    }

}

@@ -463,32 +463,39 @@
 sertKillSuccess(
+false, 
 targetIndex, cur
@@ -497,32 +497,32 @@
 , currentList);%0A
-
 %0A        //delet
@@ -681,32 +681,259 @@
 sertKillSuccess(
+false, targetIndex, currentList);%0A%0A        //delete using the short command%0A        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);%0A        targetIndex = currentList.length;%0A        assertKillSuccess(true, 
 targetIndex, cur
@@ -1138,16 +1138,23 @@
 Success(
+false, 
 targetIn
@@ -1165,32 +1165,34 @@
  currentList);%0A%0A
+%0A%0A
         //invali
@@ -1450,16 +1450,103 @@
 orrect.%0A
+     * @param usesShortCommand Whether to use the short or long version of the command%0A
      * @
@@ -1748,16 +1748,42 @@
 Success(
+boolean usesShortCommand, 
 int targ
@@ -2034,32 +2034,150 @@
 exOneIndexed);%0A%0A
+        if (usesShortCommand) %7B%0A            commandBox.runCommand(%22k %22 + targetIndexOneIndexed);%0A        %7D else %7B%0A    
         commandB
@@ -2215,32 +2215,42 @@
 ndexOneIndexed);
+%0A        %7D
 %0A%0A        //conf

Add test for shortened kill command