package guitests;

import org.junit.Test;

import seedu.taskell.commons.core.Messages;
import seedu.taskell.testutil.TestTask;

import static org.junit.Assert.assertTrue;

public class FindCommandTest extends TaskManagerGuiTest {

    @Test
    public void find_nonEmptyList() {
        assertFindResult("find Mark"); //no results
        assertFindResult("find Meier", td.benson, td.daniel); //multiple results

        //find after deleting one result
        commandBox.runCommand("delete 1");
        assertFindResult("find Meier",td.daniel);
    }
    
    @Test
    public void find_nonEmptyList_byTag() {
        assertFindResult("find chicken"); //no results
        assertFindResult("find friends", td.alice, td.benson); //multiple results

        //find after deleting one result
        commandBox.runCommand("delete 1");
        assertFindResult("find friends", td.benson);
    }

    @Test
    public void find_emptyList(){
        commandBox.runCommand("clear");
        assertFindResult("find Jean"); //no results
    }

    @Test
    public void find_invalidCommand_fail() {
        commandBox.runCommand("findgeorge");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
    }

    private void assertFindResult(String command, TestTask... expectedHits ) {
        commandBox.runCommand(command);
        assertListSize(expectedHits.length);
        assertResultMessage(expectedHits.length + " tasks listed!");
        assertTrue(taskListPanel.isListMatching(expectedHits));
    }
}

@@ -881,24 +881,151 @@
 nson);%0A    %7D
+%0A    %0A    @Test%0A    public void find_byMoreThanOneTags() %7B%0A        assertFindResult(%22find friends owesMoney%22, td.benson);%0A    %7D
 %0A%0A    @Test%0A

update tests to search by more than one tags