public void ZScheduledTask_IsInDanger()
        {
            // Arrange
            DateTime deadline = new DateTime(2018, 5, 6, 12, 0, 0);
            TimeSpan buffer   = TimeSpan.FromDays(1);

            task.Deadline = deadline;
            task.ZBuffer  = buffer;

            // Assume
            Assume.That(task.GetUrgentDate(), Is.EqualTo(new DateTime(2018, 5, 5, 12, 0, 0)));

            // Assert
            Assert.That(task.IsUrgent, Is.True);
            Assert.That(task.IsInDanger(), Is.True);
        }
        public void ZTaskManager_GetAndUpdateCurrentTask()
        {
            // Arrange
            foreach (ITask task in tasks)
            {
                manager.PushTask(task);
            }

            ITask          lastTask   = tasks[tasks.Count - 1];
            ZScheduledTask mostUrgent = pTasks[0];

            // Select the most urgent task
            int priorityListLength = pTasks.Count;

            for (int i = 1; i < priorityListLength; ++i)
            {
                if (pTasks[i].GetUrgentDate() < mostUrgent.GetUrgentDate())
                {
                    mostUrgent = pTasks[i];
                }
            }


            // Assume
            Assume.That(manager.CurrentTask, Is.EqualTo(lastTask));

            // Act I - push priority
            foreach (var task in pTasks) // tasks with priority
            {
                manager.PushTaskWithPriority(task);
            }

            // Assert I - Current Task is still stale
            Assert.That(manager.CurrentTask, Is.EqualTo(lastTask));

            // Act II - update Current Task
            manager.Update();

            // Assert II - Current Task is updated
            Assert.That(manager.CurrentTask, Is.EqualTo(mostUrgent));
        }
Example #3
0
        public void PriorityList_GetMostUrgentTask(string method)
        {
            // Arrange
            var            getFunc    = SelectViewMethod(method);
            ZPriorityList  pList      = new ZPriorityList();
            ZScheduledTask mostUrgent = pTasks[0];

            for (int i = 1; i < pTasks.Count; i++)
            {
                if (pTasks[i].GetUrgentDate() < mostUrgent.GetUrgentDate())
                {
                    mostUrgent = pTasks[i];
                }
            }

            // Assume
            Assume.That(mostUrgent, Is.EqualTo(pTasks[2])); // manually selected

            // Act
            PushAllTasks(pList, pTasks);

            // Assert
            Assert.That(getFunc(pList), Is.EqualTo(mostUrgent));
        }