Ejemplo n.º 1
0
        public async Task ArchiveTasksCommandHandler_ReturnsArchivedTasks()
        {
            var command = new ArchiveTasksCommand();
            var result  = await _handler.Handle(command, new CancellationToken());

            result.Should().HaveCount(2);
        }
Ejemplo n.º 2
0
        public async Task ArchiveTasksCommandHandler_MovesCompletedTasksToDone()
        {
            var command = new ArchiveTasksCommand();

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

            _taskFile.DoneLines.Should().HaveCount(4);
        }
Ejemplo n.º 3
0
        public async Task ArchiveTasksCommandHandler_RemovesTasksAndBlankLinesFromTodo()
        {
            var command = new ArchiveTasksCommand();

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

            _taskFile.TaskLines.Should().HaveCount(5);
        }
Ejemplo n.º 4
0
        private async Task Archive(string configFile)
        {
            var command = new ArchiveTasksCommand();
            var result  = await Mediator.Send(command);

            foreach (var task in result)
            {
                Console.WriteLine(task.ToString(true));
            }
            Console.WriteLine($"TODO: {result.Count} tasks archived.");
        }
Ejemplo n.º 5
0
        public Task <IList <TaskItem> > Handle(ArchiveTasksCommand request, CancellationToken cancellationToken)
        {
            IList <TaskItem> completed = new List <TaskItem>();
            var tasks = _taskFile.LoadTasks(_config.TodoFile);

            _taskFile.Clear(_config.TodoFile);
            foreach (var task in tasks)
            {
                if (task.Completed)
                {
                    _taskFile.AppendTo(_config.DoneFile, task.ToString());
                    completed.Add(task);
                }
                else
                {
                    _taskFile.AppendTo(_config.TodoFile, task.ToString());
                }
            }
            return(Task.FromResult(completed));
        }
Ejemplo n.º 6
0
 public async Task <Response> HandleAsync(ArchiveTasksCommand cmd, CancellationToken ct)
 {
     return(await InitiateLongRunningProcess(NextPipeProcessType.ArchiveCompletedTasks,
                                             nameof(ArchiveTasksCommand),
                                             async() => { await _eventPublisher.PublishAsync(new ArchiveTasksEvent(), ct); }));
 }