public static async Task <CreateTodoListResponseDto> ExecuteAsync(
     [HttpTrigger("post", Route = "todo")] HttpRequest httpRequest,
     [Request] CreateTodoListRequestDto requestDto,
     [Authorization] UserDocument userDocument,
     [Validation(ValidatorType = typeof(CreateTodoListValidator),
                 ThrowIfInvalid = true)] ValidationResult validationResult,
     [Service] ITodoService service,
     CancellationToken cancellationToken)
 => await service.CreateTodoListAsync(requestDto, userDocument, cancellationToken);
Exemplo n.º 2
0
        public async Task CreateTodoListAsync()
        {
            var requestDto = new CreateTodoListRequestDto
            {
                Title       = TodoServiceTest.GetRandomToken(),
                Description = TodoServiceTest.GetRandomToken(),
            };
            var userDocument = new UserDocument();

            _documentClientMock.Setup(client => client.InsertAsync(
                                          It.IsAny <TodoListDocument>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new TodoListDocument
            {
                Id = Guid.NewGuid(),
            });

            var responseDto = await _todoService.CreateTodoListAsync(
                requestDto, userDocument, CancellationToken.None);

            Assert.IsNotNull(responseDto);
            Assert.IsFalse(responseDto.TodoListId == default, "TodoListId == default");

            _documentClientMock.Verify();
        }