public void ListPriorityQueryHandler_HandlesNullTerms() { var command = new ListPriorityQuery { Priorities = "A", Terms = null }; Assert.DoesNotThrowAsync(async() => await _handler.Handle(command, new CancellationToken())); }
public async Task ListPriorityQueryHandler_ReturnsAllTasksWithoutBlanksWithoutSearchTerms() { var command = new ListPriorityQuery { Priorities = "A-Z", Terms = new string[0] }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(7); }
public async Task ListPriorityQueryHandler_ReturnsSinglePriority() { var command = new ListPriorityQuery { Priorities = "B", Terms = new string[0] }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(2); result.Tasks.First().Text.Should().StartWith("(B) "); }
public async Task ListPriorityQueryHandler_HandlesNegativeAndPositiveSearchTerms() { var command = new ListPriorityQuery { Priorities = "A-E", Terms = new string[] { "-+project", "@context" } }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(1); result.Tasks.First().Text.Should().Be("(D) This is lower @context"); }
public async Task ListPriorityQueryHandler_HandlesMultipleNegativeSearchTerms() { var command = new ListPriorityQuery { Priorities = "A-B", Terms = new string[] { "-+project", "-@context" } }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(2); result.Tasks.First().Text.Should().Be("(A) This is high priority"); }
public async Task ListPriorityQueryHandler_ReturnsTasksWithSearchTerms() { var command = new ListPriorityQuery { Priorities = "A", Terms = new string[] { "+project" } }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(1); result.Tasks.First().Text.Should().Be("(A) This is also a high priority +project @context"); }
public async Task ListPriorityQueryHandler_HandlesMultipleLowercasePriorities() { var command = new ListPriorityQuery { Priorities = "a-b", Terms = null }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(4); result.Tasks.First().Text.Should().Be("(A) This is high priority"); result.Tasks.Last().Text.Should().Be("(B) This is secondary"); }
public async Task ListPriorityQueryHandler_WithoutPriority_ReturnsAllPrioritizedTasks(string priorities) { var command = new ListPriorityQuery { Priorities = priorities, Terms = null }; ListPriorityResponse result = await _handler.Handle(command, new CancellationToken()); result.Tasks.Should().HaveCount(7); result.Tasks.First().Text.Should().Be("(A) This is high priority"); result.Tasks.Last().Text.Should().Be("(Z) Very low priority with +project"); }
private async Task ListPriorities(string priorities, string[] terms, bool plain) { var query = new ListPriorityQuery { Priorities = priorities, 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.Tasks.Count} of {result.TotalTasks} tasks shown"); }