public async Task <ActionResult <CompleteTasksDataViewModel> > ListTasks(bool myTasks, bool sharedTasks, bool accepted, bool refused, bool done, int activePage, int pageSize)
        {
            var tasksListQuery = new ListTasksQuery(myTasks, sharedTasks, accepted, refused, done, activePage, pageSize);
            var data           = await Mediator.Send(tasksListQuery);

            return(new CompleteTasksDataViewModel(Mapper.Map <List <DelegatedTask>, List <DelegatedTaskViewModel> >(data.Item1), data.Item2));
        }
        public void ListTasksQueryHandler_HandlesNullTerms()
        {
            var command = new ListTasksQuery {
                Filename = _config.TodoFile, Terms = null
            };

            Assert.DoesNotThrowAsync(async() => await _handler.Handle(command, new CancellationToken()));
        }
        public async Task ListTasksQueryHandler_AndsTheQueryForMultipleSearchTerms()
        {
            var command = new ListTasksQuery {
                Filename = _config.TodoFile, Terms = new string[] { "+project", "@context" }
            };
            ListTasksResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.Should().HaveCount(1);
        }
        public async Task ListTasksQueryHandler_ReturnsTasksWithSearchTerms()
        {
            var command = new ListTasksQuery {
                Filename = _config.TodoFile, Terms = new string[] { "+project" }
            };
            ListTasksResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.Should().HaveCount(2);
        }
        public async Task ListTasksQueryHandler_WithOtherFilename_ReturnsTasksFromOtherFile()
        {
            var command = new ListTasksQuery {
                Filename = "Other.txt", Terms = new string[0]
            };
            ListTasksResponse result = await _handler.Handle(command, new CancellationToken());

            result.Tasks.Should().HaveCount(2);
        }
        public async Task ListTasksQueryHandler_ReturnsTasksInPriorityOrder()
        {
            var command = new ListTasksQuery {
                Filename = _config.TodoFile, Terms = null
            };
            ListTasksResponse 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 2020-10-16 This is something to do!");
        }
Ejemplo n.º 7
0
        private async Task ListFile(string filename, string[] terms, bool plain)
        {
            var query = new ListTasksQuery {
                Filename = filename, 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($"{filename.ToUpper()}: {result.Tasks.Count} of {result.TotalTasks} tasks shown");
        }