package guitests;

import static org.junit.Assert.assertTrue;
import static seedu.taskboss.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import org.junit.Test;

import seedu.taskboss.logic.commands.SortCommand;
import seedu.taskboss.testutil.TestTask;

public class SortCommandTest extends TaskBossGuiTest {

    @Test
    public void sort() {
        //sort by end date time
        TestTask[] expectedList = new TestTask[] {td.carl, td.elle, td.alice,
            td.daniel, td.benson, td.george, td.fiona};
        assertSortSuccess(false, expectedList, "ed");

        //sort by start date time
        TestTask[] expectedList2 = new TestTask[] {td.george, td.alice, td.carl,
            td.daniel, td.fiona, td.elle, td.benson};
        assertSortSuccess(false, expectedList2, "sd");

        //sort by end date time short command
        TestTask[] expectedList3 = new TestTask[] {td.carl, td.elle, td.alice,
            td.daniel, td.benson, td.george, td.fiona};
        assertSortSuccess(true, expectedList3, "ed");

        //sort by priority short command
        TestTask[] expectedList4 = new TestTask[] {td.carl, td.alice, td.daniel,
            td.george, td.elle, td.benson, td.fiona};
        assertSortSuccess(true, expectedList4, "p");

        //invalid sort command
        commandBox.runCommand("sort byname");
        assertResultMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));

        //invalid sort command
        commandBox.runCommand("sort");
        assertResultMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));

        //invalid sort command
        commandBox.runCommand("s");
        assertResultMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));

    }

    private void assertSortSuccess(boolean isShortCommand, TestTask[] expectedList, String sortType) {
        if (isShortCommand) {
            commandBox.runCommand("s " + sortType);
        } else {
            commandBox.runCommand("sort " + sortType);
        }

        //confirm the list is sorted according to the specified sort type
        assertTrue(taskListPanel.isListMatching(expectedList));
    }
}


@@ -311,16 +311,226 @@
 Test %7B%0A%0A
+    //---------------- Tests for SortCommand --------------------------------------%0A%0A    /*%0A     * Valid equivalence partitions:%0A     * - end date time%0A     * - start date time%0A     * - priority level%0A     */%0A%0A
     @Tes
@@ -558,32 +558,56 @@
 t() %7B%0A        //
+ Equivalence partition: 
 sort by end date
@@ -803,32 +803,37 @@
 d%22);%0A%0A        //
+ EP: 
 sort by start da
@@ -1033,32 +1033,37 @@
 d%22);%0A%0A        //
+ EP: 
 sort by end date
@@ -1282,16 +1282,21 @@
       //
+ EP: 
 sort by 
@@ -1509,32 +1509,37 @@
 p%22);%0A%0A        //
+ EP: 
 invalid sort com
@@ -1695,32 +1695,37 @@
 E));%0A%0A        //
+ EP: 
 invalid sort com
@@ -1767,16 +1767,62 @@
 %22sort%22);
+ // boundary value with no sort type specified
 %0A       
@@ -1928,16 +1928,21 @@
       //
+ EP: 
 invalid 
@@ -1989,16 +1989,62 @@
 nd(%22s%22);
+ // boundary value with no sort type specified
 %0A       

Add design heuristics::SortCommandTest