示例#1
0
        public async Task ShouldCompleteTodo()
        {
            const string name = "name";
            var          id   = Guid.NewGuid();
            var          now  = DateTime.Now;

            _context.Todos.Add(new Todo
            {
                Id   = id,
                Name = name,
            });
            _context.SaveChanges();

            _mock.Mock <IUtcNowProvider>()
            .Setup(provider => provider.UtcNow())
            .Returns(now);

            await _service.CompleteAsync(new TodoCompleteRequest { Id = id });

            var expected = new Todo
            {
                Id          = id,
                Name        = name,
                CompletedAt = now
            };

            _context.GetDatabaseValues <Todo>().Single()
            .Should()
            .BeEquivalentTo(expected);
        }
 public async Task <TodoDTO> Complete([FromBody] TodoCompleteRequest request)
 {
     return(_mapper.Map <TodoDTO>(await _service.CompleteAsync(request)));
 }