示例#1
0
        public async Task Should_return_error_when_consultation_accepted_but_no_room_is_available()
        {
            var conferenceId = TestConference.Id;
            var requestedBy  = TestConference.GetParticipants()[2];
            var requestedFor = TestConference.GetParticipants()[3];

            VideoPlatformServiceMock
            .Setup(x => x.StartPrivateConsultationAsync(TestConference, requestedBy, requestedFor))
            .ThrowsAsync(new DomainRuleException("Unavailable room", "No consultation rooms available"));

            // make sure no rooms are available
            TestConference.Participants[1].UpdateCurrentRoom(RoomType.ConsultationRoom1);
            TestConference.Participants[4].UpdateCurrentRoom(RoomType.ConsultationRoom2);

            var answer = ConsultationAnswer.Accepted;

            var request = new ConsultationRequest
            {
                ConferenceId = conferenceId,
                RequestedBy  = requestedBy.Id,
                RequestedFor = requestedFor.Id,
                Answer       = answer
            };

            var result = await Controller.HandleConsultationRequestAsync(request);

            var typedResult = (ObjectResult)result;

            typedResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            ((SerializableError)typedResult.Value).ContainsKeyAndErrorMessage("ConsultationRoom", "No consultation room available");
            VideoPlatformServiceMock.Verify(x =>
                                            x.StartPrivateConsultationAsync(TestConference, requestedBy, requestedFor), Times.Once);
            VideoPlatformServiceMock.VerifyNoOtherCalls();
        }
        public async Task should_return_kinly_status_code_on_error()
        {
            var conferenceId = Guid.NewGuid();
            var request      = new TransferParticipantRequest
            {
                ParticipantId = Guid.NewGuid(),
                TransferType  = TransferType.Call
            };
            var message    = "Transfer Error";
            var response   = "Unable to transfer participant";
            var statusCode = (int)HttpStatusCode.Unauthorized;
            var exception  =
                new KinlyApiException(message, statusCode, response, null, null);

            VideoPlatformServiceMock
            .Setup(x => x.TransferParticipantAsync(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <RoomType>(),
                                                   It.IsAny <RoomType>())).ThrowsAsync(exception);

            var result = await Controller.TransferParticipantAsync(conferenceId, request);

            result.Should().BeOfType <ObjectResult>();
            var typedResult = (ObjectResult)result;

            typedResult.StatusCode.Should().Be(statusCode);
            typedResult.Value.Should().Be(response);
        }
        public async Task should_move_room_into_hearing_room()
        {
            var conferenceId    = TestConference.Id;
            var participant     = TestConference.Participants.First(x => x.UserRole == UserRole.Individual);
            var interpreterRoom = new ParticipantRoom(TestConference.Id, "Interpreter1", VirtualCourtRoomType.Civilian);

            interpreterRoom.SetProtectedProperty(nameof(interpreterRoom.Id), 999);
            var roomParticipant = new RoomParticipant(participant.Id)
            {
                Room   = interpreterRoom,
                RoomId = interpreterRoom.Id
            };

            interpreterRoom.AddParticipant(roomParticipant);
            participant.RoomParticipants.Add(roomParticipant);
            UpdateConferenceQueryMock();

            var request = new TransferParticipantRequest
            {
                ParticipantId = participant.Id,
                TransferType  = TransferType.Call
            };

            var result = await Controller.TransferParticipantAsync(conferenceId, request);

            result.Should().BeOfType <AcceptedResult>();

            VideoPlatformServiceMock.Verify(
                x => x.TransferParticipantAsync(conferenceId, interpreterRoom.Id.ToString(),
                                                RoomType.WaitingRoom.ToString(), RoomType.HearingRoom.ToString()), Times.Once);
        }
        public async Task Should_close_conference_for_given_valid_conference_id()
        {
            VideoPlatformServiceMock.Setup(v => v.GetVirtualCourtRoomAsync(It.IsAny <Guid>())).ReturnsAsync((MeetingRoom)null);

            await Controller.CloseConferenceAsync(Guid.NewGuid());

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            VideoPlatformServiceMock.Verify(v => v.DeleteVirtualCourtRoomAsync(It.IsAny <Guid>()), Times.Never);
        }
        public async Task Should_close_conference_and_remove_court_room_for_given_valid_conference_id()
        {
            var meetingRoom = new MeetingRoom("admin", "judge", "participant", "node", "12345678");

            VideoPlatformServiceMock.Setup(v => v.GetVirtualCourtRoomAsync(It.IsAny <Guid>())).ReturnsAsync(meetingRoom);
            await Controller.CloseConferenceAsync(Guid.NewGuid());

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            VideoPlatformServiceMock.Verify(v => v.DeleteVirtualCourtRoomAsync(It.IsAny <Guid>()), Times.Once);
        }
        public async Task should_return_accepted_when_suspend_hearing_has_been_requested()
        {
            var conferenceId = Guid.NewGuid();

            var result = await Controller.SuspendHearingAsync(conferenceId);

            var typedResult = (AcceptedResult)result;

            typedResult.Should().NotBeNull();
            typedResult.StatusCode.Should().Be((int)HttpStatusCode.Accepted);
            VideoPlatformServiceMock.Verify(x => x.SuspendHearingAsync(conferenceId), Times.Once);
        }
示例#7
0
        public async Task should_return_accepted_when_start_hearing_has_been_requested()
        {
            var conferenceId = Guid.NewGuid();
            var request      = new StartHearingRequest
            {
                Layout = HearingLayout.OnePlus7
            };
            var result = await Controller.StartVideoHearingAsync(conferenceId, request);

            var typedResult = (AcceptedResult)result;

            typedResult.Should().NotBeNull();
            typedResult.StatusCode.Should().Be((int)HttpStatusCode.Accepted);
            VideoPlatformServiceMock.Verify(x => x.StartHearingAsync(conferenceId, Layout.ONE_PLUS_SEVEN), Times.Once);
        }
        public async Task Should_book_kinly_conference_and_update_meeting_room_for_given_conference_id()
        {
            var audioPlatformServiceResponse = new AudioPlatformServiceResponse(true)
            {
                IngestUrl = "http://myIngestUrl.com"
            };

            SetupCallToMockRetryService(audioPlatformServiceResponse);
            VideoPlatformServiceMock.Setup(v => v.BookVirtualCourtroomAsync(It.IsAny <Guid>(), It.IsAny <bool>(), audioPlatformServiceResponse.IngestUrl, It.IsAny <IEnumerable <EndpointDto> >())).ReturnsAsync(MeetingRoom);

            await Controller.BookKinlyMeetingRoomAsync(Guid.NewGuid(), true, audioPlatformServiceResponse.IngestUrl, new EndpointDto[] {});

            VideoPlatformServiceMock.Verify(v => v.BookVirtualCourtroomAsync(It.IsAny <Guid>(), It.IsAny <bool>(), audioPlatformServiceResponse.IngestUrl, It.IsAny <IEnumerable <EndpointDto> >()), Times.Once);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <UpdateMeetingRoomCommand>()), Times.Once);
        }
        public void should_return_internal_server_error_when_transfer_type_is_not_handled()
        {
            var conferenceId = Guid.NewGuid();
            var request      = new TransferParticipantRequest
            {
                ParticipantId = Guid.NewGuid(),
                TransferType  = null
            };

            Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                           Controller.TransferParticipantAsync(conferenceId, request));

            VideoPlatformServiceMock.Verify(
                x => x.TransferParticipantAsync(conferenceId, request.ParticipantId, It.IsAny <RoomType>(),
                                                It.IsAny <RoomType>()), Times.Never);
        }
示例#10
0
        public async Task Should_leave_private_consultation_with_valid_conference_and_room_type()
        {
            var conferenceId = TestConference.Id;
            var request      = TestConference.GetParticipants()[1];

            var leaveConsultationRequest = new LeaveConsultationRequest {
                ConferenceId  = conferenceId,
                ParticipantId = request.Id
            };

            await Controller.LeavePrivateConsultationAsync(leaveConsultationRequest);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Once);
            VideoPlatformServiceMock.Verify(v => v.StopPrivateConsultationAsync(TestConference, RoomType.ConsultationRoom1), Times.Once);
            VideoPlatformServiceMock.VerifyNoOtherCalls();
        }
        public async Task should_dismiss_participant_from_hearing_room()
        {
            var conferenceId = Guid.NewGuid();
            var request      = new TransferParticipantRequest
            {
                ParticipantId = Guid.NewGuid(),
                TransferType  = TransferType.Dismiss
            };

            var result = await Controller.TransferParticipantAsync(conferenceId, request);

            result.Should().BeOfType <AcceptedResult>();

            VideoPlatformServiceMock.Verify(
                x => x.TransferParticipantAsync(conferenceId, request.ParticipantId, RoomType.HearingRoom,
                                                RoomType.WaitingRoom), Times.Once);
        }
        public void should_return_internal_server_error_when_transfer_type_is_not_handled()
        {
            var conferenceId = TestConference.Id;
            var participant  = TestConference.Participants.First(x => x.UserRole == UserRole.Individual);
            var request      = new TransferParticipantRequest
            {
                ParticipantId = participant.Id,
                TransferType  = null
            };

            Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                           Controller.TransferParticipantAsync(conferenceId, request));

            VideoPlatformServiceMock.Verify(
                x => x.TransferParticipantAsync(conferenceId, request.ParticipantId.ToString(), It.IsAny <string>(),
                                                It.IsAny <string>()), Times.Never);
        }
        public async Task should_dismiss_participant_from_hearing_room()
        {
            var conferenceId = TestConference.Id;
            var participant  = TestConference.Participants.First(x => x.UserRole == UserRole.Individual);
            var request      = new TransferParticipantRequest
            {
                ParticipantId = participant.Id,
                TransferType  = TransferType.Dismiss
            };

            var result = await Controller.TransferParticipantAsync(conferenceId, request);

            result.Should().BeOfType <AcceptedResult>();

            VideoPlatformServiceMock.Verify(
                x => x.TransferParticipantAsync(conferenceId, request.ParticipantId.ToString(), RoomType.HearingRoom.ToString(),
                                                RoomType.WaitingRoom.ToString()), Times.Once);
        }
示例#14
0
        public async Task Should_update_requested_conference_successfully()
        {
            var request = new UpdateConferenceRequest
            {
                HearingRefId      = Guid.NewGuid(),
                CaseName          = "CaseName",
                ScheduledDateTime = DateTime.Now,
                ScheduledDuration = 10,
                CaseType          = "CaseType",
                CaseNumber        = "CaseNo"
            };

            VideoPlatformServiceMock.Setup(v => v.UpdateVirtualCourtRoomAsync(It.IsAny <Guid>(), It.IsAny <bool>(), It.IsAny <List <EndpointDto> >()));

            await Controller.UpdateConferenceAsync(request);

            VideoPlatformServiceMock.Setup(v => v.UpdateVirtualCourtRoomAsync(It.IsAny <Guid>(), It.IsAny <bool>(), It.IsAny <List <EndpointDto> >()));
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <UpdateConferenceDetailsCommand>()), Times.Once);
        }
        [Test] public async Task should_return_kinly_status_code_on_error()
        {
            var conferenceId = Guid.NewGuid();
            var message      = "Auto Test Error";
            var response     = "You're not allowed to suspend this hearing";
            var statusCode   = (int)HttpStatusCode.Unauthorized;
            var exception    =
                new KinlyApiException(message, statusCode, response, null, null);

            VideoPlatformServiceMock.Setup(x => x.SuspendHearingAsync(It.IsAny <Guid>()))
            .ThrowsAsync(exception);

            var result = await Controller.SuspendHearingAsync(conferenceId);

            var typedResult = (ObjectResult)result;

            typedResult.Should().NotBeNull();
            typedResult.StatusCode.Should().Be(statusCode);
            typedResult.Value.Should().Be(response);
        }
        public async Task Should_not_transfer_participant_when_consultation_is_not_accepted()
        {
            var conferenceId = TestConference.Id;
            var participant  = TestConference.GetParticipants()[3];

            var roomFrom = participant.CurrentRoom.Value;
            var request  = new AdminConsultationRequest
            {
                ConferenceId     = conferenceId,
                ParticipantId    = participant.Id,
                ConsultationRoom = RoomType.ConsultationRoom1,
                Answer           = ConsultationAnswer.Rejected
            };

            await Controller.RespondToAdminConsultationRequestAsync(request);

            VideoPlatformServiceMock.Verify(x =>
                                            x.TransferParticipantAsync(conferenceId, participant.Id, roomFrom, request.ConsultationRoom),
                                            Times.Never);
            VideoPlatformServiceMock.VerifyNoOtherCalls();
        }
示例#17
0
        public async Task Should_raise_notification_to_requester_and_admin_when_consultation_is_accepted()
        {
            var conferenceId = TestConference.Id;
            var requestedBy  = TestConference.GetParticipants()[2];
            var requestedFor = TestConference.GetParticipants()[3];

            var answer = ConsultationAnswer.Accepted;

            var request = new ConsultationRequest
            {
                ConferenceId = conferenceId,
                RequestedBy  = requestedBy.Id,
                RequestedFor = requestedFor.Id,
                Answer       = answer
            };

            await Controller.HandleConsultationRequestAsync(request);

            CommandHandlerMock.Verify(x => x.Handle(It.Is <SaveEventCommand>(s => s.Reason == $"Consultation with {requestedFor.DisplayName}")), Times.Once);
            VideoPlatformServiceMock.Verify(x =>
                                            x.StartPrivateConsultationAsync(TestConference, requestedBy, requestedFor), Times.Once);
            VideoPlatformServiceMock.VerifyNoOtherCalls();
        }