package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

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

public class ListByCategoryCommandTest extends TaskBossGuiTest {
    @Test
    public void listByCategory_nonEmptyList() {
        assertListByCategoryResult("listcategory wife"); // no results
        assertListByCategoryResult("listcategory friends", td.alice, td.benson); // multiple results

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

    @Test
    public void listByCategory_emptyList() {
        commandBox.runCommand("clear");
        assertListByCategoryResult("listcategory friends"); // no results
    }

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

    private void assertListByCategoryResult(String command, TestTask... expectedHits) {
        commandBox.runCommand(command);
        assertListSize(expectedHits.length);
        assertTrue(taskListPanel.isListMatching(expectedHits));
    }
}

@@ -54,16 +54,99 @@
 ertTrue;
+%0Aimport static seedu.taskboss.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
 %0A%0Aimport
@@ -208,16 +208,76 @@
 ssages;%0A
+import seedu.taskboss.logic.commands.ListByCategoryCommand;%0A
 import s
@@ -473,25 +473,19 @@
 lt(%22list
-category 
+ c/
 wife%22); 
@@ -534,33 +534,27 @@
 Result(%22list
-category 
+ c/
 friends%22, td
@@ -602,44 +602,65 @@
     
+%7D%0A%0A
     
-//find after deleting one result
+@Test%0A    public void listByCategory_emptyList() %7B
 %0A   
@@ -691,16 +691,13 @@
 nd(%22
-delete 1
+clear
 %22);%0A
@@ -736,21 +736,23 @@
 lt(%22
-find 
+list c/
 friends%22
 , td
@@ -747,29 +747,32 @@
 friends%22
-, td.benson);
+); // no results
 %0A    %7D%0A%0A
@@ -808,33 +808,43 @@
 tByCategory_
-emptyList
+unknownCommand_fail
 () %7B%0A       
@@ -859,37 +859,37 @@
 Box.runCommand(%22
-clear
+listc
 %22);%0A        asse
@@ -894,67 +894,56 @@
 sert
-ListByCategoryResult(%22listcategory friends%22); // no results
+ResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
 %0A   
@@ -1050,18 +1050,15 @@
 list
-by
+ t/
 cate
-gory
 %22);%0A
@@ -1085,33 +1085,38 @@
 Message(
-Messages.
+String.format(
 MESSAGE_
 UNKNOWN_
@@ -1103,39 +1103,39 @@
 mat(MESSAGE_
-UNKNOWN
+INVALID
 _COMMAND
 );%0A    %7D%0A%0A  
@@ -1114,32 +1114,93 @@
 _INVALID_COMMAND
+_FORMAT,%0A                ListByCategoryCommand.MESSAGE_USAGE)
 );%0A    %7D%0A%0A    pr

update testcases