public async Task GetAppointmentAsync_ValidId_ShouldReturnExpectedAppointment() { // Arrange var existingAppointment = new GetAppointmentPayload { Id = Guid.NewGuid().ToString(), }; var expectedResponseContent = new StringContent(JsonConvert.SerializeObject(existingAppointment, this.fixture.JsonSerializerSettings)); var expectedResponse = new HttpResponseMessage { Content = expectedResponseContent, }; var appointmentApi = this.fixture.GetAppointmentApi(expectedResponse); var getAppointmentByIdResponse = new GetAppointmentByIdResponse(); // Act Func <Task> act = async() => getAppointmentByIdResponse = await appointmentApi.GetAppointmentByIdAsync(existingAppointment.Id); // Assert await act.Should().NotThrowAsync(); getAppointmentByIdResponse.Id.Should().Be(existingAppointment.Id); }
public async Task UpdateAppointmentAsync_ValidRequest_ShouldReturnUpdatedAppointment() { // Arrange var existingAppointment = new GetAppointmentPayload { Id = Guid.NewGuid().ToString(), Subject = "TestSubject", }; var updateAppointmentRequest = new UpdateAppointmentRequest { Subject = "NewSubject", }; var expectedUpdatedAppointment = new UpdateAppointmentResponse { Id = existingAppointment.Id, Subject = updateAppointmentRequest.Subject, }; var expectedResponseContent = new StringContent(JsonConvert.SerializeObject(expectedUpdatedAppointment, this.fixture.JsonSerializerSettings)); var expectedResponse = new HttpResponseMessage { Content = expectedResponseContent, }; var appointmentApi = this.fixture.GetAppointmentApi(expectedResponse); var updateAppointmentResponse = new UpdateAppointmentResponse(); // Act Func <Task> act = async() => updateAppointmentResponse = await appointmentApi.UpdateAppointmentAsync(existingAppointment.Id, updateAppointmentRequest); // Assert await act.Should().NotThrowAsync(); using (new AssertionScope()) { updateAppointmentResponse.Id.Should().Be(existingAppointment.Id); updateAppointmentResponse.Subject.Should().Be(expectedUpdatedAppointment.Subject); } }