Exemplo n.º 1
0
        public async Task Should_delete_hearings()
        {
            var request = new DeleteTestHearingDataRequest()
            {
                PartialHearingCaseName = "Test"
            };

            var idsResponse = new List <Guid>()
            {
                Guid.NewGuid()
            };

            BookingsApiService
            .Setup(x => x.DeleteHearingsByPartialCaseText(It.IsAny <DeleteTestHearingDataRequest>()))
            .ReturnsAsync(idsResponse);

            VideoApiClient
            .Setup(x => x.DeleteAudioApplicationAsync(It.IsAny <Guid>()))
            .Returns(Task.CompletedTask);

            var response = await Controller.DeleteTestDataByPartialCaseText(request);

            var result = (ObjectResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var deletionDetails = (DeletedResponse)result.Value;

            deletionDetails.NumberOfDeletedHearings.Should().Be(1);
        }
Exemplo n.º 2
0
        public async Task Should_return_bad_request_with_invalid_request()
        {
            BookingsApiService
            .Setup(x => x.DeleteHearingsByPartialCaseText(It.IsAny <DeleteTestHearingDataRequest>()))
            .ThrowsAsync(CreateBookingsApiException("Request invalid", HttpStatusCode.BadRequest));

            var response = await Controller.DeleteTestDataByPartialCaseText(new DeleteTestHearingDataRequest());

            var result = (ObjectResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
        public async Task Should_throw_not_found_if_conference_not_created()
        {
            var hearingId = Guid.NewGuid();
            var request   = new UpdateBookingRequestBuilder().Build();

            BookingsApiService
            .Setup(x => x.UpdateBookingStatusPolling(It.IsAny <Guid>(), It.IsAny <UpdateBookingStatusRequest>()))
            .Returns(Task.CompletedTask);

            VideoApiService
            .Setup(x => x.GetConferenceByHearingIdPolling(It.IsAny <Guid>()))
            .ThrowsAsync(CreateVideoApiException("Conference not found", HttpStatusCode.NotFound));

            var response = await Controller.ConfirmHearingById(hearingId, request);

            response.Should().NotBeNull();

            var result = (ObjectResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Exemplo n.º 4
0
        public async Task Should_return_bad_request_with_video_api_internal_error()
        {
            var idsResponse = new List <Guid>()
            {
                Guid.NewGuid()
            };

            BookingsApiService
            .Setup(x => x.DeleteHearingsByPartialCaseText(It.IsAny <DeleteTestHearingDataRequest>()))
            .ReturnsAsync(idsResponse);

            VideoApiClient
            .Setup(x => x.DeleteAudioApplicationAsync(It.IsAny <Guid>()))
            .ThrowsAsync(CreateVideoApiException("Request failed", HttpStatusCode.BadRequest));

            var response = await Controller.DeleteTestDataByPartialCaseText(new DeleteTestHearingDataRequest());

            var result = (ObjectResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
        public async Task Should_throw_error_if_update_booking_status_failed()
        {
            var hearingId = Guid.NewGuid();
            var conferenceDetailsResponse = CreateConferenceDetailsResponse();

            var request = new UpdateBookingRequestBuilder().Build();

            VideoApiService
            .Setup(x => x.GetConferenceByHearingIdPolling(It.IsAny <Guid>()))
            .ReturnsAsync(conferenceDetailsResponse);

            BookingsApiService
            .Setup(x => x.UpdateBookingStatusPolling(It.IsAny <Guid>(), It.IsAny <UpdateBookingStatusRequest>()))
            .ThrowsAsync(CreateBookingsApiException("Hearing not found", HttpStatusCode.NotFound));

            var response = await Controller.ConfirmHearingById(hearingId, request);

            response.Should().NotBeNull();

            var result = (ObjectResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }