public async Task GetProjectByIdAsync_ValidRequest_ShouldReturnExpectedProject() { // Arrange var existingProject = new GetProjectPayload { Id = Guid.NewGuid().ToString(), }; var expectedResponseContent = new StringContent(JsonConvert.SerializeObject(existingProject, this.fixture.JsonSerializerSettings)); var expectedResponse = new HttpResponseMessage { Content = expectedResponseContent, }; var projectApi = this.fixture.GetProjectApi(expectedResponse); var getProjectByIdResponse = new GetProjectByIdResponse(); // Act Func <Task> act = async() => getProjectByIdResponse = await projectApi.GetProjectByIdAsync(existingProject.Id); // Assert await act.Should().NotThrowAsync(); getProjectByIdResponse.Id.Should().Be(existingProject.Id); }
public override async Task <ActionResult <GetProjectByIdResponse> > HandleAsync([FromRoute] GetProjectByIdRequest request, CancellationToken cancellationToken) { var spec = new ProjectByIdWithItemsSpec(request.ProjectId); var entity = await _repository.GetBySpecAsync(spec); // TODO: pass cancellation token if (entity == null) { return(NotFound()); } var response = new GetProjectByIdResponse ( id: entity.Id, name: entity.Name, items: entity.Items.Select(item => new ToDoItemRecord(item.Id, item.Title, item.Description, item.IsDone)).ToList() ); return(Ok(response)); }