public void EditEndDateTest()
        {
            Add adder = new Add();
            Edit target = new Edit();

            adder.addTask(Utility.TEST_EDIT_TASK_TASK);
            target.editTask(Utility.TEST_EDIT_TASK_ET);

            string expected = Utility.TEST_EDITED_TASK_ET;
            string actual = Storage.getTaskList()[0].setEnd + " ";

            Assert.AreEqual(expected, actual);

            expected = Utility.TEST_EDIT_TASK_INITIAL_TASK_DESCRIPTION;
            actual = Storage.getTaskList()[0].setTaskDescription;

            Assert.AreEqual(expected, actual);

            expected = Utility.TEST_EDIT_TASK_INITIAL_START;
            actual = Storage.getTaskList()[0].setStart + " " ;

            Assert.AreEqual(expected, actual);

            expected = Utility.TEST_EDIT_TASK_INITIAL_TAG;
            actual = Storage.getTaskList()[0].setTag;

            Assert.AreEqual(expected, actual);
        }
        public void addTaskInvalidTest()
        {
            Add target = new Add();

            int expected = 0; // 0 as all invalid tasks should fail
            int actual;

            target.addTask(Utility.TEST_INVALID_ADDTASK_ET_BEFORE_ST);
            target.addTask(Utility.TEST_INVALID_ADDTASK_ED_BEFORE_SD);
            target.addTask(Utility.TEST_INVALID_ST_ADDTASK_ALL_TIME_T);
            target.addTask(Utility.TEST_INVALID_ET_ADDTASK_ALL_TIME_T);
            target.addTask(Utility.TEST_INVALID_SD_ADDTASK_ALL_TIME_T);
            target.addTask(Utility.TEST_INVALID_ED_ADDTASK_ALL_TIME_T);

            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
        }
        public void deleteCorrectTaskTest()
        {
            Delete target = new Delete();
            Add adder = new Add();
            adder.addTask(Utility.TEST_NORMAL_ADDTASK_1);
            adder.addTask(Utility.TEST_NORMAL_ADDTASK_2);
            adder.addTask(Utility.TEST_NORMAL_ADDTASK_3);

            target.deleteTask(Utility.TEST_DELETE_TASK_3);//Task 1:"Go swimming" should be deleted
            string expected = Utility.TEST_NORMAL_ADDTASK_1;
            string actual = Storage.getTaskList()[1].setTaskDescription+Utility.SPACE_CHAR;
            Assert.AreEqual(expected, actual);

            expected = Utility.TEST_DELETE_TASK_3_EXPECTED_TD; ;
            actual = Storage.getTaskList()[0].setTaskDescription+Utility.SPACE_CHAR;
            Assert.AreEqual(expected, actual);
        }
        public void addDiffTaskDescriptionsTest()
        {
            Add target = new Add();

            //adding 5 different Tasks
            target.addTask(Utility.TEST_NORMAL_ADDTASK_1);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_2);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_3);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_4);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_5);

            int expected = 5;
            int actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);

            string actualtaskdes = Storage.getTaskList()[4].setTaskDescription+Utility.SPACE_CHAR;
            string expectedtaskdes = Utility.TEST_NORMAL_ADDTASK_5;//have to take auto sort into consideration
            Assert.AreEqual(expectedtaskdes, actualtaskdes);
        }
        public void addTaskNormalTest()
        {
            Add target = new Add();

            int expected = 18; // number of successful tasks
            int actual;

            target.addTask(Utility.TEST_NORMAL_ADDTASK_NO_DETAILS);
            expected = 1;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST);
            expected = 2;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST_ET);
            expected = 3;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST_ET_SD);
            expected = 4;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST_ET_ED);
            expected = 5;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST_SD);
            expected = 6;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST_SD_ED);
            expected = 7;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ST_ED);
            expected = 8;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ET);
            expected = 9;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ET_SD);
            expected = 10;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ET_SD_ED);
            expected = 11;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ET_ED);
            expected = 12;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_SD);
            expected = 13;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_SD_ED);
            expected = 14;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ED);
            expected = 15;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ALL_TIME);
            expected = 16;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_ALL_TIME_T);
            expected = 17;
            actual = Storage.getTaskList().Count;
            Assert.AreEqual(expected, actual);
            target.addTask(Utility.TEST_NORMAL_ADDTASK_T);
            expected = 18;
            actual = Storage.getTaskList().Count;

            Assert.AreEqual(expected, actual);
        }
        public void addTaskWierdTest()
        {
            Add target = new Add();

            int expected = 3; // Number of successful tasks
            int actual;

            target.addTask(Utility.TEST_WIERD_ADDTASK_MULTIPLE_ST);
            target.addTask(Utility.TEST_WIERD_ADDTASK_ET_BEFORE_ST_SAME_DATE);
            target.addTask(Utility.TEST_WIERD_ADDTASK_MIXED_COMMANDS_ALL_TIME_T);

            actual = Storage.getTaskList().Count;

            Assert.AreEqual(expected, actual);
        }
 public void getIndexTest2()
 {
     Add adder=new Add();
     adder.addTask(Utility.TEST_EDIT_TASK_TASK);
     Edit target = new Edit();
     string input = Utility.TEST_EDIT_TASK_TASK_DESCRIPTION;
     int expected = 1;
     int actual;
     actual = target.getIndex(input);
     Assert.AreEqual(expected, actual);
 }
 public void toStringListTest()
 {
     Add adder = new Add();
     adder.addTask(Utility.TEST_NORMAL_ADDTASK_3);
     Storage.toStringList();
     string actual = Storage.getStringTaskList()[0];
     string expected = Utility.TEST_STORAGE_TASK_EXPECTED;
     Assert.AreEqual(expected, actual);
 }
        //@author A0091525H
        public static List<Task> determineCommand(string input)
        {
            ILog log = LogManager.GetLogger(typeof(OperationHandler));
            log4net.Config.XmlConfigurator.Configure();
            log.Info(Utility.LOG_DETERMINE_COMMAND_STARTED);

            List<string> prevCommand = new List<string>();
            string command = extractFirstWord(input + Utility.SPACE_CHAR);
            UndoRedo undoRedoObj = new UndoRedo();

            prevCommand.Add(command);

            if (String.Equals(input, Utility.COMMAND_EXIT, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_EXIT_COMMAND_IDENTIFIED);
                Process p = Process.GetCurrentProcess();
                p.Kill();
                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_ARCHIVE, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                Complete completeObj = new Complete();
                return completeObj.returnCompletedTaskList();
            }

            else if (string.Equals(input, Utility.COMMAND_HELP, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                showHelp();
                return Storage.getTaskList();
            }

            else if (string.Equals(input, Utility.COMMAND_UNDO, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_UNDO_COMMAND_IDENTIFIED);
                if (undoRedoObj.getUndolist().Count == 0)
                {
                    UI.statusMessageLabel.Text = Utility.ERROR_INVALID_UNDO_COMMAND;
                }
                else
                {
                    undoRedoObj.undo();
                    UI.statusMessageLabel.Text = Utility.STATUS_TASK_UNDO;
                }
                return Storage.getTaskList();
            }

            else if (string.Equals(input, Utility.COMMAND_REDO, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_REDO_COMMAND_IDENTIFIED);
                if (undoRedoObj.getRedolist().Count == 0)
                {
                    UI.statusMessageLabel.Text = Utility.ERROR_INVALID_REDO_COMMAND;
                }
                else
                {
                    undoRedoObj.redo();
                    UI.statusMessageLabel.Text = Utility.STATUS_TASK_REDO;
                }
                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_COMPLETE, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_COMPLETE_COMMAND_STARTED);
                undoRedoObj.addUndoTask();

                Complete completeObj = new Complete();

                UI.statusMessageLabel.Text = completeObj.changeCompleteStatus(input,true);

                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_UNCOMPLETE, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_UNCOMPLETE_COMMAND_STARTED);
                undoRedoObj.addUndoTask();

                Complete completeObj = new Complete();

                UI.statusMessageLabel.Text = completeObj.changeCompleteStatus(input,false);

                return Storage.getTaskList();
            }

            else if (String.Equals(command, Utility.COMMAND_SEARCH, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_SEARCH_COMMAND_IDENTIFIED);
                input = input + Utility.SPACE_CHAR;
                int firstIndex = input.IndexOf(Utility.SPACE_CHAR);
                int lastIndex = input.Length;
                string searchKeyword = input.Substring(firstIndex, input.Length - firstIndex - 1).Trim();

                return PowerSearch.instantSearch(searchKeyword);
            }

            else if (string.Equals(command, Utility.COMMAND_DELETE, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_DELETE_COMMAND_IDENTIFIED);
                undoRedoObj.addUndoTask();
                Delete deleteObj = new Delete();
                UI.statusMessageLabel.Text = deleteObj.deleteTask(input);
                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_CLEAR, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                undoRedoObj.addUndoTask();
                Storage.getTaskList().Clear();
                Storage.updateStorage();
                UI.statusMessageLabel.Text = Utility.STATUS_CLEARED;
                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_EDIT, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                log.Info(Utility.LOG_EDIT_COMMAND_IDENTIFIED);
                undoRedoObj.addUndoTask();
                Edit editobj = new Edit();
                UI.statusMessageLabel.Text = editobj.editTask(input);
                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_ALL, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                return Storage.getTaskList();
            }

            else if (string.Equals(command, Utility.COMMAND_ADD, StringComparison.CurrentCultureIgnoreCase) == true || input.Length != 0)
            {
                log.Info(Utility.LOG_ADD_COMMAND_IDENTIFIED);
                undoRedoObj.addUndoTask();
                Add addObj = new Add();
                UI.statusMessageLabel.Text = addObj.addTask(input);
                return Storage.getTaskList();
            }

            else
            {
                log.Info(Utility.LOG_COMMAND_NOT_IDENTIFIED);
                UI.statusMessageLabel.Text = Utility.ERROR_INVALID_INPUT;
                return Storage.getTaskList();
            }
        }