コード例 #1
0
        public void ZTaskManager_GetAllTasks()
        {
            // Arrange I
            foreach (var task  in tasks)
            {
                manager.PushTask(task);
            }
            List <ITask> copy = new List <ITask>(tasks);

            // Assert I
            Assert.That(manager.GetAllTasks(), Is.EquivalentTo(tasks));

            // Arrange II
            var archivedTask = manager.CurrentTask;

            manager.ArchiveCurrentTask(Category.Obsolete);
            copy.Remove(archivedTask);

            // Assert II
            Assert.That(manager.GetAllTasks(), Is.EquivalentTo(copy));

            // Arrange III
            foreach (var task in pTasks)
            {
                manager.PushTaskWithPriority(task);
            }
            copy.AddRange(pTasks);

            // Assert III
            Assert.That(manager.GetAllTasks(), Is.EquivalentTo(copy));

            // Arrange IV
            archivedTask = manager.CurrentTask;
            manager.ArchiveCurrentTask(Category.Obsolete);
            copy.Remove(archivedTask);

            // Assert IV
            Assert.That(manager.GetAllTasks(), Is.EquivalentTo(copy));
        }
コード例 #2
0
        public void View_AllTasks(string[] commands)
        {
            bool detail = false;

            switch (commands.Length)
            {
            case 1:
                break;

            case 2:
                if (commands[1].Equals(ShowDetail))
                {
                    detail = true;
                }
                else
                {
                    throw new BadCommandException(commands);
                }
                break;

            default:
                throw new BadCommandException();
            }

            var tasks = manager.GetAllTasks();

            if (detail)
            {
                Print(FormatUtil.BreakLine);
                ConsoleUtil.WriteTasksInDetail(tasks);
                detail = false;
            }
            else
            {
                for (int i = 0; i < tasks.Count; ++i)
                {
                    Print(i + ". " + tasks[i].Title);
                }
            }
        }