コード例 #1
0
        public void ListAllQueryHandler_HandlesNullTerms()
        {
            var command = new ListAllQuery {
                Terms = null
            };

            Assert.DoesNotThrowAsync(async() => await _handler.Handle(command, new CancellationToken()));
        }
コード例 #2
0
        public async Task ListAllQueryHandler_ReturnsAllTasksWithoutBlanksWithoutSearchTerms()
        {
            var command = new ListAllQuery {
                Terms = new string[0]
            };
            ListAllResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.Should().HaveCount(9);
        }
コード例 #3
0
        public async Task ListAllQueryHandler_SortsCompletedTasksLast()
        {
            var command = new ListAllQuery {
                Terms = null
            };
            ListAllResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks[6].Text.Should().Be("x This is complete @context");
        }
コード例 #4
0
        public async Task ListAllQueryHandler_ReturnsTasksWithSearchTerms()
        {
            var command = new ListAllQuery {
                Terms = new string[] { "+project" }
            };
            ListAllResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.Should().HaveCount(3);
            result.ShownTasks.Should().Be(2);
            result.ShownDone.Should().Be(1);
            result.TotalTasks.Should().Be(7);
            result.TotalDone.Should().Be(2);
        }
コード例 #5
0
        public async Task ListAllQueryHandler_HandlesNegativeAndPositiveSearchTerms()
        {
            var command = new ListAllQuery {
                Terms = new string[] { "-+project", "@context" }
            };
            ListAllResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.Should().HaveCount(2);
            result.ShownTasks.Should().Be(1);
            result.ShownDone.Should().Be(1);
            result.TotalTasks.Should().Be(7);
            result.TotalDone.Should().Be(2);
        }
コード例 #6
0
        public async Task ListAllQueryHandler_ReturnsTasksInPriorityOrder()
        {
            var command = new ListAllQuery {
                Terms = null
            };
            ListAllResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.First().Text.Should().Be("(A) This is high priority");
            result.Tasks.Last().Text.Should().Be("x Two +project");
            result.ShownTasks.Should().Be(7);
            result.ShownDone.Should().Be(2);
            result.TotalTasks.Should().Be(7);
            result.TotalDone.Should().Be(2);
        }
コード例 #7
0
        private async Task ListAll(string[] terms, bool plain)
        {
            var query = new ListAllQuery {
                Terms = terms
            };
            var result = await Mediator.Send(query);

            foreach (var task in result.Tasks)
            {
                if (plain)
                {
                    Console.WriteLine(task.ToColorString(true, Configuration).ToPlainString());
                }
                else
                {
                    ColorConsole.WriteLine(task.ToColorString(true, Configuration).ToColorTokens());
                }
            }
            Console.WriteLine("--");
            Console.WriteLine($"TODO: {result.ShownTasks} of {result.TotalTasks} tasks shown");
            Console.WriteLine($"DONE: {result.ShownDone} of {result.TotalDone} tasks shown");
            Console.WriteLine($"total {result.ShownTasks + result.ShownDone} of {result.TotalTasks + result.TotalDone} tasks shown");
        }