package guitests;

import static org.junit.Assert.assertTrue;
import static seedu.task.logic.commands.DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS;

import org.junit.Test;

import seedu.task.testutil.TestTask;
import seedu.task.testutil.TestUtil;

public class DeleteCommandTest extends AddressBookGuiTest {

    @Test
    public void delete() {
        //  valid-partition: Boundary value just above the boundary
        //  delete the first in the list

        for (int i = 0; i < currentList.length; i++) commandBox.runCommand(currentList[i].getAddCommand());

        int targetIndex = 1;
        assertDeleteSuccess(targetIndex, currentList);
        //  valid-partition: Boundary value just below the boundary
        //  delete the last in the list
        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);
        targetIndex = currentList.length;
        assertDeleteSuccess(targetIndex, currentList);



        //  valid-partition: Boundary value just below the boundary
        //delete from the middle of the list
        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);

        for (int i = 0; i < currentList.length; i++) commandBox.runCommand(currentList[i].getAddCommand());

        targetIndex = currentList.length / 2;
        assertDeleteSuccess(targetIndex, currentList);

        //invalid partition: value outside the boundary
        //invalid index
        commandBox.runCommand("delete " + currentList.length + 1);
        assertResultMessage("The task index provided is invalid");

    }

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

        commandBox.runCommand("delete " + targetIndexOneIndexed);

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

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

}

@@ -445,16 +445,69 @@
 he list%0A
+        TestTask%5B%5D currentList = %7Btd.fiona , td.ida%7D;
 %0A       
@@ -1167,16 +1167,100 @@
 Index);%0A
+        TestTask%5B%5D temp = %7Btd.fiona , td.ida , td.hoon%7D;%0A        currentList = temp;
 %0A       

fix deletecommand