package guitests;

import org.junit.Test;

import seedu.address.commons.core.Messages;
import seedu.address.logic.commands.DoneCommand;
import seedu.address.testutil.TestTask;

import static org.junit.Assert.assertTrue;

//@@author A0146123R
public class DoneCommandTest extends TaskManagerGuiTest {

    @Test
    public void done() {
        TestTask[] currentList = td.getTypicalTasks();
        
        // Mark task as done by index
        currentList[0].markAsDone();
        assertDoneSuccess("done 1", currentList);
        
        // Mark task as done by name
        currentList[4].markAsDone();
        assertDoneSuccess("done Work", currentList);
        
        // Mark task as done by name with multiple satisfied
        currentList[2].markAsDone();
        commandBox.runCommand("done friends");
        assertResultMessage(DoneCommand.MULTIPLE_TASK_SATISFY_KEYWORD);
        assertDoneSuccess("done 3", currentList);
        
        // Invalid index
        commandBox.runCommand("done 12");
        assertResultMessage(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
        
        // Invalid name
        commandBox.runCommand("done dinner");
        assertResultMessage(DoneCommand.TASK_NOT_FOUND);
    }

    private void assertDoneSuccess(String command, TestTask... currentList) {
        commandBox.runCommand(command);
        assertTrue(taskListPanel.isListMatching(currentList));
    }

}

@@ -218,28 +218,256 @@
 e;%0A%0A
-//@@author A0146123R
+import org.junit.Before;%0A%0A//@@author A0146123R%0A%0A/**%0A * test for done command execution on gui%0A * @author LiXiaowei%0A * %0A * use scenarios: 1) mark a task as done by index as the last shown list%0A *                2) mark a task as done by name%0A *%0A */%0A
 %0Apub
@@ -525,18 +525,57 @@
 t %7B%0A
+    
 %0A    
-@
 Test
+Task%5B%5D currentList;%0A    %0A    @Before
 %0A   
@@ -591,15 +591,20 @@
 oid 
-done
+setUpLists
 ()
- 
 %7B%0A  
@@ -608,27 +608,16 @@
 %0A       
- TestTask%5B%5D
  current
@@ -624,11 +624,9 @@
 List
- = 
+=
 td.g
@@ -643,24 +643,26 @@
 asks();%0A    
+%7D%0A
     %0A       
@@ -662,209 +662,624 @@
     
-    // Mark task as done by index%0A        currentList%5B0%5D.markAsDone();%0A        assertDoneSuccess(%22done 1%22, currentList);%0A        %0A        // Mark task as done by name%0A        currentList%5B4%5D.markAsDone(
+//---------------------------------valid cases--------------------------------------------%0A%0A    //test for scenario1: mark done by index%0A    %0A    @Test%0A    public void markDoneByIndex_successful() %7B%0A        %0A        currentList%5B0%5D.markAsDone();%0A        assertDoneSuccess(%22done 1%22, currentList);%0A        %0A    %7D%0A    %0A    //test for scenario 2: mark done by name%0A    %0A    @Test%0A    public void markDoneByName_successful()%7B%0A        %0A        // Mark task as done by name%0A        currentList%5B4%5D.markAsDone();%0A        commandBox.runCommand(%22done Work%22);%0A        assertResultMessage(DoneCommand.MULTIPLE_TASK_SATISFY_KEYWORD
 );%0A 
@@ -1309,20 +1309,17 @@
 s(%22done 
-Work
+1
 %22, curre
@@ -1624,24 +1624,211 @@
     
-// Invalid index
+%0A    %7D%0A    %0A    //-------------------------------------invalid cases---------------------------------------%0A    %0A    //test for invalid index%0A    %0A    @Test%0A    public void markDoneByInvalidIndex_fail()%7B
 %0A   
@@ -1959,27 +1959,120 @@
     
-    // Invalid name
+%7D%0A    %0A    //test for nonexistant name%0A    %0A    @Test%0A    public void markDoneByNonExistantName_fail()%7B%0A        
 %0A   

refactor done command test in gui