public static async Task <CreateTodoListTaskResponseDto> ExecuteAsync( [HttpTrigger("post", Route = "todo/{todoListId}/task")] HttpRequest httpRequest, [Request] CreateTodoListTaskRequestDto requestDto, [Document] TodoListDocument todoListDocument, [Authorization] UserDocument userDocument, [Validation(ValidatorType = typeof(CreateTodoListTaskValidator), ThrowIfInvalid = true)] ValidationResult validationResult, [Service] ITodoService service, CancellationToken cancellationToken) => await service.CreateTodoListTaskAsync(requestDto, todoListDocument, userDocument, cancellationToken);
public async Task CreateTodoListTaskAsync() { var requestDto = new CreateTodoListTaskRequestDto { TodoListId = Guid.NewGuid(), Title = TodoServiceTest.GetRandomToken(), Description = TodoServiceTest.GetRandomToken(), Deadline = DateTime.UtcNow.AddDays(20), }; var todoListDocument = new TodoListDocument { Id = requestDto.TodoListId, }; var userDocument = new UserDocument(); _documentClientMock.Setup(client => client.UpdateAsync( It.IsAny <TodoListDocument>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new TodoListDocument()); await _todoService.CreateTodoListTaskAsync(requestDto, todoListDocument, userDocument, CancellationToken.None); _documentClientMock.Verify(); }
/// <summary>Initializes a new instance of the <see cref="AzureFunctionsCustomBindingSample.Api.Validators.CreateTodoListTaskValidator"/> class.</summary> /// <param name="requestDto">An object that represents data to create a task for a TODO list.</param> public CreateTodoListTaskValidator(CreateTodoListTaskRequestDto requestDto) => _requestDto = requestDto ?? throw new ArgumentNullException(nameof(requestDto));