Exemple #1
0
        public void ShouldRequireValidTermId()
        {
            var command = new DeleteTermCommand {
                Id = 99
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
        public async Task DeleteTermCommandHandler_TermFound_UpdatesTaskInFile()
        {
            var command = new DeleteTermCommand {
                ItemNumber = 2, Term = "+project"
            };

            _ = await _handler.Handle(command, new CancellationToken());

            _taskFile.TaskLines[1].Should().Be("2020-10-16 This is something to do with @context and a!");
        }
        public async Task DeleteTermCommandHandler_LineNotFound_ReturnsNoTask()
        {
            var command = new DeleteTermCommand {
                ItemNumber = 10, Term = "+project"
            };
            var result = await _handler.Handle(command, new CancellationToken());

            result.Success.Should().BeFalse();
            result.Task.Should().BeNull();
        }
        public async Task DeleteTermCommandHandler_MultipleTermFound_UpdatesTaskInFile()
        {
            var command = new DeleteTermCommand {
                ItemNumber = 6, Term = "@context"
            };

            _ = await _handler.Handle(command, new CancellationToken());

            // This is 4 because the blank line gets removed too
            _taskFile.TaskLines[4].Should().Be("(B) This is in between with");
        }
        public async Task DeleteTermCommandHandler_MultipleTermFound_ReturnsUpdatedTask()
        {
            var command = new DeleteTermCommand {
                ItemNumber = 6, Term = "@context"
            };
            var result = await _handler.Handle(command, new CancellationToken());

            result.Success.Should().BeTrue();
            result.Task.Should().NotBeNull();
            result.Task.LineNumber.Should().Be(6);
            result.Task.Description.Should().Be("This is in between with");
        }
        public async Task DeleteTermCommandHandler_TermFound_ReturnsUpdatedTask()
        {
            var command = new DeleteTermCommand {
                ItemNumber = 2, Term = "+project"
            };
            var result = await _handler.Handle(command, new CancellationToken());

            result.Success.Should().BeTrue();
            result.Task.Should().NotBeNull();
            result.Task.LineNumber.Should().Be(2);
            result.Task.Description.Should().Be("This is something to do with @context and a!");
        }
Exemple #7
0
        private async Task DeleteTerm(TaskItem task, string term)
        {
            Console.WriteLine(task.ToString(true));
            var command = new DeleteTermCommand {
                ItemNumber = task.LineNumber, Term = term
            };
            var result = await Mediator.Send(command);

            if (result.Success)
            {
                Console.WriteLine($"TODO: Removed '{term}' from task.");
                Console.WriteLine(result.Task.ToString(true));
            }
            else
            {
                Console.WriteLine($"TODO: {term} not found; no removal done.");
            }
        }