Пример #1
0
        private static void SetupTaskList(TaskList tasks)
        {
            Task firstTask  = tasks.AddTask("New Task");
            Task secondTask = tasks.AddTask("Another Task");

            tasks.CompleteTask(firstTask.TaskId);
        }
Пример #2
0
        public void EditTask_Level1()
        {
            string   name     = "Level 1 Task";
            TaskList taskList = new TaskList();

            taskList.Reset();

            //Parent Task
            Task level0_task = new Task("Root Task", DateTime.MaxValue, null);

            taskList.AddTask(level0_task);

            //SubTask
            Task level1_task = new Task(name, DateTime.MaxValue, level0_task);

            taskList.AddTask(level1_task);

            //New SubTask
            Task new_level1_task = new Task(name, DateTime.MinValue, level0_task);

            taskList.EditTask(level1_task, new_level1_task);

            ApplicationDataContainer TaskContainer = taskList.GetTaskContainer();

            //Ensure the parent container is still valid
            ApplicationDataContainer level0TaskContainer = TaskContainer.Containers[level0_task.Id];

            CheckContainerMatch(level0_task, level0TaskContainer);

            //Check that the child container has been updated
            ApplicationDataContainer level1TaskContainer = level0TaskContainer.Containers[level1_task.Id];

            CheckContainerMatch(new_level1_task, level1TaskContainer);
        }
Пример #3
0
        public void AddTask_should_not_add_task_with_same_name()
        {
            Task     task = new Task("WC", "Acheter du papier toilettes", ApplicationTime.Now, TaskState.TODO);
            TaskList list = new TaskList();

            list.AddTask(task);
            ArgumentException exception = Assert.Throws <ArgumentException>(() => list.AddTask(task));

            Assert.Equal("Task with this name already exist", exception.Message);
        }
Пример #4
0
 public void SetUp()
 {
     form = new TaskList("afwaf", new List <Task>(), false);
     a    = new Task("a", false, new DateTime(2020, 05, 01), new DateTime(2020, 06, 01), 4, false);
     b    = new Task("b", false, new DateTime(2020, 05, 02), new DateTime(2020, 06, 02), 5, false);
     c    = new Task("c", false, new DateTime(2020, 05, 03), new DateTime(2020, 06, 03), 3, false);
     form.AddTask(a);
     form.AddTask(b);
     form.AddTask(c);
 }
Пример #5
0
        public void AddingTwoTasksShouldResultInSeparateIds()
        {
            TaskList tasks     = new TaskList();
            Task     firstTask = tasks.AddTask("Test task");

            Assert.AreEqual(0, firstTask.TaskId, string.Format("Task ID should be 0, not {0}", firstTask.TaskId));

            Task secondTask = tasks.AddTask("Test task");

            Assert.AreEqual(1, secondTask.TaskId, string.Format("Task ID should be 1, not {0}", secondTask.TaskId));
        }
Пример #6
0
        public void FindTask_should_return_task_from_task_list()
        {
            Task     task1 = new Task("WC", "Acheter du papier toilettes", ApplicationTime.Now, TaskState.TODO);
            Task     task2 = new Task("PAIN", "Manger du pain", ApplicationTime.Now, TaskState.TODO);
            Task     task3 = new Task("ECOLE", "Rendre le projet à l'heure", ApplicationTime.Now, TaskState.TODO);
            TaskList list  = new TaskList();

            list.AddTask(task1);
            list.AddTask(task2);
            list.AddTask(task3);
            Assert.Equal(list.FindTask(task3.name), task3);
        }
Пример #7
0
        public void SetTaskToDone_should_set_task_to_done()
        {
            Task     task1 = new Task("WC", "Acheter du papier toilettes", ApplicationTime.Now, TaskState.TODO);
            Task     task2 = new Task("PAIN", "Manger du pain", ApplicationTime.Now, TaskState.TODO);
            Task     task3 = new Task("ECOLE", "Rendre le projet à l'heure", ApplicationTime.Now, TaskState.TODO);
            TaskList list  = new TaskList();

            list.AddTask(task1);
            list.AddTask(task2);
            list.AddTask(task3);
            list.SetTaskToDone(task3);
            Assert.Equal(TaskState.DONE, list.FindTask(task3.name).state);
        }
Пример #8
0
        public void orderTaskList_should_order_task()
        {
            Task     task1 = new Task("WC", "Acheter du papier toilettes", ApplicationTime.Now, TaskState.TODO);
            Task     task2 = new Task("PAIN", "Manger du pain", ApplicationTime.Now.AddDays(1), TaskState.TODO);
            Task     task3 = new Task("ECOLE", "Rendre le projet à l'heure", ApplicationTime.Now.AddDays(-2), TaskState.TODO);
            TaskList list  = new TaskList();

            list.AddTask(task1);
            list.AddTask(task2);
            list.AddTask(task3);
            list.OrderTaskList();
            Assert.Equal(list.tasks[0], task3);
        }
Пример #9
0
        public void AddTaskShouldIncreaseTaskCount()
        {
            TaskList tasks = new TaskList();

            tasks.AddTask("Test task");
            Assert.AreEqual(1, tasks.Count);
        }
Пример #10
0
        public void AddTaskShouldReturnTaskWithId()
        {
            TaskList tasks     = new TaskList();
            Task     addedTask = tasks.AddTask("Test task");
            int      taskId    = addedTask.TaskId;

            Assert.AreEqual(0, taskId, string.Format("Task ID should be 1, not {0}", taskId));
        }
Пример #11
0
        public void AddTask_should_add_task_to_task_list()
        {
            Task     task = new Task("WC", "Acheter du papier toilettes", ApplicationTime.Now, TaskState.TODO);
            TaskList list = new TaskList();

            list.AddTask(task);
            Assert.Contains(task, list.tasks);
        }
Пример #12
0
        public void AddTaskToTheList()
        {
            var initialTaskCount = _sampletasklist.Tasks.Count();

            _sampletasklist.AddTask("New Task");

            Assert.Equal(initialTaskCount + 1, _sampletasklist.Tasks.Count());
        }
Пример #13
0
        static void AddTask()
        {
            Console.WriteLine();                      //Makes things pretty
            _taskList.Tasks.Add(_taskList.AddTask()); //Accesses the list from _taskList and runs the AddTask method that returns type Task

            Console.WriteLine("You've added a task, returning to main menu");

            OperateConsoleMenu();
        }
Пример #14
0
        public void RemoveTask_should_remove_task_from_task_list()
        {
            Task     task = new Task("WC", "Acheter du papier toilettes", ApplicationTime.Now, TaskState.TODO);
            TaskList list = new TaskList();

            list.AddTask(task);
            list.RemoveTask(task);
            Assert.DoesNotContain(task, list.tasks);
        }
Пример #15
0
        public void CompleteTaskShouldMarkTaskComplete()
        {
            TaskList tasks   = new TaskList();
            Task     newTask = tasks.AddTask("Task to complete");

            Assert.IsNull(newTask.CompletionDate, "Tasks should not be completed when they are first added.");

            tasks.CompleteTask(newTask.TaskId);
            Assert.IsNotNull(newTask.CompletionDate, "Completing a task needs to add a completion date.");
            Assert.AreEqual <DateTime>(DateTime.Today, newTask.CompletionDate.Value, "Completion date should be today.");
        }
Пример #16
0
        public void NewTask()
        {
            Console.Clear();
            Session.LineBreak();
            Console.Write("  Task Name: ");
            var taskName = Console.ReadLine();

            if (TaskList.AddTask(taskName))
            {
                TaskList.Save();
                DisplayTask(TaskList.GetLatestTaskIndex());
            }
        }
Пример #17
0
        public void DeleteTask_Level1()
        {
            string   name     = "Level 1 Task";
            TaskList taskList = new TaskList();

            taskList.Reset();

            //Parent Task
            Task level0_task = new Task("Root Task", DateTime.MaxValue, null);

            taskList.AddTask(level0_task);

            //SubTask
            Task level1_task = new Task(name, DateTime.MaxValue, level0_task);

            taskList.AddTask(level1_task);

            taskList.DeleteTask(level1_task);

            bool exists = CheckContainerExists(level1_task, taskList.GetTaskContainer());

            Assert.IsFalse(exists);
        }
Пример #18
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     if (tasklist.HasSameTask(arguments.GetParameter(1)) == false)
     {
         Task task = new Task();
         FileIO loader = new FileIO();
         task.TaskDescription = arguments.GetParameter(1);
         task.IsNewTask = true;
         task = CheckDueDate(arguments, task);
         tasklist.AddTask(ref task);
         loader.SaveTasks(tasklist.GetTasks());
         Console.WriteLine("Task {0} added", task.TaskDescription);
     }
     else Console.WriteLine("Task already in list");
 }
Пример #19
0
        public void AddTask_Test()
        {
            //Arrange - create a new Task object and a new task list
            TaskList tasks = new TaskList("");
            Task     task  = new Task("test", DateTime.Now);


            //Act - Call AddTask
            task = tasks.AddTask(task);
            //Assert - got a non-zero id, list has a c count of 1, task is not null
            Assert.IsNotNull(task);
            Assert.AreEqual(1, tasks.Count);
            Assert.AreNotEqual(0, task.TaskId);
            Assert.IsTrue(task.TaskId > 0, "AddTask should return a positive integer for new Id"); // important to add a name for what you are testing
        }
Пример #20
0
    /// <summary>
    /// Called by the DONE button to create a task
    /// </summary>
    public void Done()
    {
        //check if the input is valid
        if (Validate(nameInput.text, tagSelect.SelectedTag))
        {
            //add the task to the list
            taskList.AddTask(nameInput.text,
                             daySelect.SelectedDay, monthSelect.SelectedMonth, monthSelect.SelectedYear,
                             tagSelect.SelectedTag.name);

            screenControl.SetScreen(ScreenUI.Task);

            taskList.SaveData();
        }
    }
Пример #21
0
        public void AddTask_Root()
        {
            string   name     = "Root Task";
            TaskList taskList = new TaskList();

            taskList.Reset();

            Task level0_task = new Task(name, DateTime.MaxValue, null);

            taskList.AddTask(level0_task);

            ApplicationDataContainer TaskContainer = taskList.GetTaskContainer();
            ApplicationDataContainer taskContainer = TaskContainer.Containers[level0_task.Id];

            CheckContainerMatch(level0_task, taskContainer);
        }
Пример #22
0
        public void DeleteTask_Root()
        {
            TaskList taskList = new TaskList();

            taskList.Reset();

            Task level0_task = new Task("Level 0 Task", DateTime.MaxValue, null);

            taskList.AddTask(level0_task);

            taskList.DeleteTask(level0_task);

            bool exists = CheckContainerExists(level0_task, taskList.GetTaskContainer());

            Assert.IsFalse(exists);
        }
Пример #23
0
        public void SetTasks(string taskName, DateTime dueDate, string type)
        {
            taskList.AddTask(taskName, dueDate);

            if (type.Equals("Physical"))
            {
                physicalList.AddTask(taskName, dueDate);
            }
            else if (type.Equals("Mental"))
            {
                mentalList.AddTask(taskName, dueDate);
            }
            else if (type.Equals("Social"))
            {
                socialList.AddTask(taskName, dueDate);
            }
            else if (type.Equals("Financial"))
            {
                financialList.AddTask(taskName, dueDate);
            }
        }
Пример #24
0
    protected void ButtonAddTask_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            Task task = new Task(TextBoxName.Text)
            {
                Category   = DropDownListCategories.SelectedValue,
                TaskStatus = CheckBoxIsCompleted.Checked ? Task.Status.Completed : Task.Status.Pending
            };

            try
            {
                TaskList taskList = Session[typeof(TaskList).Name] as TaskList;
                taskList.AddTask(task);
                LabelAddResults.Text = string.Format("Successfully added Task [{0}]", task);
            }
            catch (Exception ex)
            {
                LabelAddResults.Text = ex.Message;
            }
        }
    }
Пример #25
0
        public void PersistTasksWhenSaving()
        {
            var saveTaskList = new TaskList(@"TestData\savedatatest.json");

            saveTaskList.AddTask("Persisted Task");
            saveTaskList.Save();

            var tasksCount = saveTaskList.Tasks.Count();
            var savedTask  = saveTaskList.GetTask(saveTaskList.GetLatestTaskIndex());

            var loadedTaskList = new TaskList(@"TestData\savedatatest.json");
            var persistedTask  = loadedTaskList.GetTask(saveTaskList.GetLatestTaskIndex());

            Assert.NotEmpty(loadedTaskList.Tasks);
            Assert.Equal(tasksCount, loadedTaskList.Tasks.Count());
            Assert.Equal(savedTask.Name, persistedTask.Name);
            Assert.Equal(savedTask.State, persistedTask.State);
            Assert.Equal(savedTask.Status, persistedTask.Status);
            Assert.Equal(savedTask.CreatedDate, persistedTask.CreatedDate);
            Assert.Equal(savedTask.Duration, persistedTask.Duration);
            Assert.Equal(savedTask.ActiveStarted, persistedTask.ActiveStarted);
            Assert.Equal(savedTask.AuditTracker, persistedTask.AuditTracker);
        }
Пример #26
0
        private static void RemoveByKey(string key, string searchPath)
        {
            var folderPaths = Directory.GetDirectories(searchPath, "*_" + key, SearchOption.AllDirectories);
            foreach (var folderPath in folderPaths)
            {
                var path = Path.Combine(folderPath, "..\\");
                if (!Directory.Exists(path))
                    continue;
                // Trace.WriteLine("deleting " + path);
                try
                {
                    Directory.Delete(path, true);
                }
                catch (Exception e)
                {
                    Trace.WriteLine("error: " + e.Message);
                }
            }
            // find any left over files by key and delete them
            var assNames = GetByKey(key, searchPath);
            var t = new TaskList();
            var gac = new GacUtility();
            foreach (var s in assNames)
            {
                string a = s;
                t.AddTask(() => gac.Remove(a));
            }
            t.WaitForAll();

        }
Пример #27
0
    private void AddTask(int duration, Waypoint waypoint, string objectiveName, int score)
    {
        int id = taskList.AddTask(objectiveName, duration);

        waypoint.InitializeValues(id, duration, score);
    }
Пример #28
0
        public override Dictionary<string, List<TaskList>> LoadData(TaskListRepository repository)
        {
            LoadXmlDataFromFile();

            RootNode = XmlData.Root;

            if (RootNode == null)
            {
                RootNode = new XElement("TaskData");
                XmlData.Add(RootNode);
            }

            Dictionary<string, List<TaskList>> taskData =
                new Dictionary<string, List<TaskList>>(StringComparer.CurrentCultureIgnoreCase);

            foreach (XElement channelNode in RootNode.Nodes())
            {
                var channelNodeAttribute = channelNode.Attribute("Name");
                if (channelNodeAttribute != null)
                {
                    List<TaskList> channelLists = new List<TaskList>();
                    foreach(XElement taskListNode in channelNode.Nodes())
                    {
                        var taskListCreator = taskListNode.Attribute(TaskListCreatorAttributeName);
                        var taskListName = taskListNode.Attribute("Name");
                        var taskListDefaultStatus = taskListNode.Attribute("DefaultStatus");

                        if(taskListCreator != null && taskListName != null && taskListDefaultStatus != null)
                        {
                            TaskList taskList = new TaskList(taskListCreator.Value, taskListName.Value, repository, taskListDefaultStatus.Value);

                            foreach(XElement taskNode in taskListNode.Nodes())
                            {
                                var taskText = taskNode.Value;
                                var taskCreatorNode = taskNode.Attribute("Creator");
                                var taskOwnerAttribute = taskNode.Attribute("Owner");
                                var taskIdAttribute = taskNode.Attribute("TaskId");
                                var taskStatus = taskNode.Attribute("Status");

                                if (taskCreatorNode != null && taskOwnerAttribute != null
                                    && taskIdAttribute != null && taskStatus != null)
                                {
                                    int taskId = Convert.ToInt32(taskIdAttribute.Value);

                                    if (taskId >= repository.NextTaskId)
                                        repository.NextTaskId = taskId + 1;

                                    Task task = new Task(taskText, taskCreatorNode.Value, taskId, taskList);
                                    task.WasTakenBy(taskOwnerAttribute.Value);
                                    task.UpdateStatus(taskStatus.Value);
                                    taskList.AddTask(task);
                                }
                            }
                            channelLists.Add(taskList);
                        }
                    }

                    taskData.Add(channelNodeAttribute.Value, channelLists);
                }
            }

            return taskData;
        }