Пример #1
0
 /// <summary>
 /// This operation generates an operation based on how this generator has been configured.
 /// </summary>
 /// <returns>The generated operation.</returns>
 public Operation CreateOperation()
 {
     Task task;
     Operation newOperation = null;
     switch (commandType)
     {
         case CommandType.ADD:
             task = Task.CreateNewTask(taskName, startDateTime, endDateTime, isSpecific);
             newOperation = new OperationAdd(task, sortType);
             break;
         case CommandType.DELETE:
             newOperation = new OperationDelete(taskName, taskRangeIndex, startDateTime, endDateTime, isSpecific, rangeIsAll, searchType, sortType);
             break;
         case CommandType.DISPLAY:
             newOperation = new OperationDisplayDefault(sortType);
             break;
         case CommandType.MODIFY:
             newOperation = new OperationModify(taskName, taskRangeIndex, startDateTime, endDateTime, isSpecific, rangeIsAll, searchType, sortType);
             break;
         case CommandType.SEARCH:
             newOperation = new OperationSearch(taskName, startDateTime, endDateTime, isSpecific, searchType, sortType);
             break;
         case CommandType.SORT:
             newOperation = new OperationSort(sortType);
             break;
         case CommandType.REDO:
             newOperation = new OperationRedo(sortType);
             break;
         case CommandType.UNDO:
             newOperation = new OperationUndo(sortType);
             break;
         case CommandType.DONE:
             newOperation = new OperationMarkAsDone(taskName, taskRangeIndex, startDateTime, endDateTime, isSpecific, rangeIsAll, searchType, sortType);
             break;
         case CommandType.UNDONE:
             newOperation = new OperationMarkAsUndone(taskName, taskRangeIndex, startDateTime, endDateTime, isSpecific, rangeIsAll, searchType, sortType);
             break;
         case CommandType.POSTPONE:
             TimeSpan postponeDuration = new TimeSpan();
             if (timeRangeType == TimeRangeType.DEFAULT)
             {
                 timeRangeType = CustomDictionary.defaultPostponeDurationType;
                 timeRangeIndex = CustomDictionary.defaultPostponeDurationLength;
             }
             switch (timeRangeType)
             {
                 case TimeRangeType.HOUR:
                     postponeDuration = new TimeSpan(timeRangeIndex, 0, 0);
                     break;
                 case TimeRangeType.DAY:
                     postponeDuration = new TimeSpan(timeRangeIndex, 0, 0, 0);
                     break;
                 case TimeRangeType.WEEK:
                     postponeDuration = new TimeSpan(timeRangeIndex * CustomDictionary.DAYS_IN_WEEK, 0, 0, 0);
                     break;
                 case TimeRangeType.MONTH:
                     postponeDuration = new TimeSpan(timeRangeIndex * CustomDictionary.DAYS_IN_MONTH, 0, 0, 0);
                     break;
             }
             newOperation = new OperationPostpone(taskName, taskRangeIndex, startDateTime, endDateTime, isSpecific, rangeIsAll, searchType, postponeDuration, sortType);
             break;
         case CommandType.SCHEDULE:
             newOperation = new OperationSchedule(taskName, (DateTime)startDateTime, endDateTime, isSpecific, timeRangeIndex, timeRangeType, sortType);
             break;
         case CommandType.EXIT:
             System.Environment.Exit(0);
             break;
     }
     return newOperation;
 }
Пример #2
0
        public void OperationSortTest()
        {
            testStorage = new Storage("OpUnittest.xml", "OpUnittestsettings.xml");
            testTaskList = testStorage.LoadTasksFromFile();

            OperationSort Op = new OperationSort(SortType.NAME);
            result = Op.Execute(testTaskList, testStorage);
            Assert.AreEqual("Sorting by name.", result.FeedbackString);
            return;
        }