public async Task Should_get_conference_by_id() { var hearing = new CreateHearingRequestBuilder().Build(); var hearingResponse = new HearingsResponseBuilder(hearing).Build(); var conferenceDetailsResponse = new ConferenceDetailsResponseBuilder(hearingResponse).Build(); var conferenceResponse = new ConferenceResponseBuilder(conferenceDetailsResponse).Build(); var testApiClientMock = new Mock <ITestApiClient>(); testApiClientMock .Setup(x => x.GetConferenceByHearingRefIdAsync(hearingResponse.Id)) .ReturnsAsync(conferenceDetailsResponse); var controller = new ConferencesController(testApiClientMock.Object, _loggerMock.Object); var response = await controller.GetConferenceByHearingRefId(hearingResponse.Id); response.Should().NotBeNull(); var result = (OkObjectResult)response; result.StatusCode.Should().Be((int)HttpStatusCode.OK); var conferenceDetails = (ConferenceResponse)result.Value; conferenceDetails.Should().NotBeNull(); conferenceDetails.Should().BeEquivalentTo(conferenceResponse); }
public async Task Should_confirm_hearing() { var hearingId = Guid.NewGuid(); var hearing = new CreateHearingRequestBuilder().Build(); var hearingResponse = new HearingsResponseBuilder(hearing).Build(); var request = new ConfirmHearingBuilder().Build(); var conferenceResponse = new ConferenceDetailsResponseBuilder(hearingResponse).Build(); var client = new Mock <ITestApiClient>(); client.Setup(x => x.ConfirmHearingByIdAsync(It.IsAny <Guid>(), It.IsAny <UpdateBookingStatusRequest>())) .ReturnsAsync(conferenceResponse); var controller = new HearingsController(client.Object, _loggerMock.Object); var result = await controller.ConfirmHearingById(hearingId, request); var typedResult = (ObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.Created); var hearingDetails = (ConferenceDetailsResponse)typedResult.Value; hearingDetails.Should().NotBeNull(); hearingDetails.Should().BeEquivalentTo(conferenceResponse); }
public void Should_map_all_properties() { var hearing = new CreateHearingRequestBuilder().Build(); var hearingResponse = new HearingsResponseBuilder(hearing).Build(); var bookingsResponse = new BookingsHearingResponseBuilder(hearingResponse).Build(); var response = HearingResponseMapper.Map(bookingsResponse); response.Should().BeEquivalentTo(bookingsResponse, options => options.ExcludingMissingMembers()); }
public void Should_map_all_properties() { var hearing = new CreateHearingRequestBuilder().Build(); var hearingResponse = new HearingsResponseBuilder(hearing).Build(); var conferenceDetailsResponse = new ConferenceDetailsResponseBuilder(hearingResponse).Build(); var conferenceResponse = new ConferenceResponseBuilder(conferenceDetailsResponse).Build(); var response = ConferenceResponseMapper.Map(conferenceDetailsResponse); response.Should().BeEquivalentTo(conferenceResponse, options => options.ExcludingMissingMembers()); }
public async Task Should_create_hearing() { var client = new Mock <ITestApiClient>(); var response = new HearingsResponseBuilder(_request).Build(); client.Setup(x => x.CreateHearingAsync(It.IsAny <CreateHearingRequest>())) .ReturnsAsync(response); var controller = new HearingsController(client.Object, _loggerMock.Object); var result = await controller.CreateHearing(_request); var typedResult = (ObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.Created); var hearingDetails = (HearingDetailsResponse)typedResult.Value; hearingDetails.Should().NotBeNull(); hearingDetails.Should().BeEquivalentTo(response); }
public async Task Should_get_all_hearings() { const string CREATED_BY = HearingsData.CREATED_BY; var client = new Mock <ITestApiClient>(); var createHearingsResponse = new HearingsResponseBuilder(_request).Build(); var bookingsHearingResponse = new BookingsHearingResponseBuilder(createHearingsResponse).Build(); var bookingsHearingsResponses = new List <BookingsHearingResponse>() { bookingsHearingResponse }; var hearingsResponse = new List <HearingResponse>() { new HearingResponse() { Case_name = bookingsHearingResponse.HearingName, Id = bookingsHearingResponse.HearingId, ScheduledDate = bookingsHearingResponse.ScheduledDateTime } }; client.Setup(x => x.GetAllHearingsAsync()) .ReturnsAsync(bookingsHearingsResponses); var controller = new HearingsController(client.Object, _loggerMock.Object); var result = await controller.GetAllHearingsByCreatedBy(CREATED_BY); var typedResult = (ObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var hearingDetails = (List <HearingResponse>)typedResult.Value; hearingDetails.Should().NotBeNull(); hearingDetails.Should().BeEquivalentTo(hearingsResponse); }