private Task UpdateRoomConnectionDetails(Conference conference, long roomId, BookedParticipantRoomResponse vmr,
                                                 string ingestUrl)
        {
            var updateCommand = new UpdateParticipantRoomConnectionDetailsCommand(conference.Id, roomId, vmr.Room_label,
                                                                                  ingestUrl, vmr.Uris.Pexip_node, vmr.Uris.Participant);

            return(_commandHandler.Handle(updateCommand));
        }
        public async Task should_create_vmr_with_kinly_if_room_is_not_available()
        {
            var expectedRoomId = 2;
            var participant    = _conference.Participants.First(x => !x.IsJudge());
            var expectedRoom   = new ParticipantRoom(_conference.Id, VirtualCourtRoomType.Witness);

            expectedRoom.SetProtectedProperty(nameof(expectedRoom.Id), expectedRoomId);
            var newVmrRoom = new BookedParticipantRoomResponse
            {
                Room_label = "Interpreter2",
                Uris       = new Uris
                {
                    Participant = "wertyui__interpreter",
                    Pexip_node  = "test.node.com"
                }
            };


            _mocker.Mock <IQueryHandler>().SetupSequence(x =>
                                                         x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >(It.Is <GetParticipantRoomsForConferenceQuery>(q =>
                                                                                                                                                                                 q.ConferenceId == _conference.Id)))
            .ReturnsAsync(new List <ParticipantRoom>())
            .ReturnsAsync(new List <ParticipantRoom> {
                expectedRoom
            });

            _mocker.Mock <ICommandHandler>().Setup(x =>
                                                   x.Handle(It.IsAny <CreateParticipantRoomCommand>())).Callback <CreateParticipantRoomCommand>(command =>
            {
                command.SetProtectedProperty(nameof(command.NewRoomId), expectedRoomId);
            });

            _mocker.Mock <ICommandHandler>().Setup(x =>
                                                   x.Handle(It.IsAny <UpdateParticipantRoomConnectionDetailsCommand>())).Callback(() =>
                                                                                                                                  expectedRoom.UpdateConnectionDetails(newVmrRoom.Room_label, "ingesturl",
                                                                                                                                                                       newVmrRoom.Uris.Pexip_node,
                                                                                                                                                                       newVmrRoom.Uris.Participant));

            _mocker.Mock <IKinlyApiClient>().Setup(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(),
                                                                                     It.Is <CreateParticipantRoomParams>(vmrRequest => vmrRequest.Participant_type == "Witness")))
            .ReturnsAsync(newVmrRoom);

            var room = await _service.GetOrCreateAWitnessVirtualRoom(_conference, participant);

            room.Should().NotBeNull();
            room.Label.Should().Be(newVmrRoom.Room_label);
            room.PexipNode.Should().Be(newVmrRoom.Uris.Pexip_node);
            room.ParticipantUri.Should().Be(newVmrRoom.Uris.Participant);

            _mocker.Mock <IKinlyApiClient>().Verify(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(),
                                                                                      It.Is <CreateParticipantRoomParams>(createParams =>
                                                                                                                          createParams.Room_label_prefix == "Interpreter" &&
                                                                                                                          createParams.Participant_type == "Witness" &&
                                                                                                                          createParams.Participant_room_id == expectedRoomId.ToString()
                                                                                                                          )), Times.Once);
        }
Пример #3
0
        public async Task should_create_a_judicial_officer_holder_room_if_one_does_not_exist()
        {
            // arrange
            var expectedRoomId = 2937;

            var existingInterpreterRoom = new ParticipantRoom(_conference.Id, "Interpreter2", VirtualCourtRoomType.Civilian);

            existingInterpreterRoom.SetProtectedProperty(nameof(existingInterpreterRoom.Id), 9999);
            var expectedJohRoom = new ParticipantRoom(_conference.Id, "PanelMember1", VirtualCourtRoomType.JudicialShared);

            expectedJohRoom.SetProtectedProperty(nameof(expectedJohRoom.Id), expectedRoomId);
            var newVmrRoom = new BookedParticipantRoomResponse
            {
                Room_label = "PanelMember1",
                Uris       = new Uris
                {
                    Participant = "wertyui__panelmember",
                    Pexip_node  = "test.node.com"
                }
            };

            var joh = _conference.Participants.First(x => x.UserRole == UserRole.JudicialOfficeHolder);

            _mocker.Mock <IQueryHandler>().SetupSequence(x =>
                                                         x.Handle <GetParticipantRoomsForConferenceQuery, List <ParticipantRoom> >(
                                                             It.Is <GetParticipantRoomsForConferenceQuery>(q =>
                                                                                                           q.ConferenceId == _conference.Id)))
            .ReturnsAsync(new List <ParticipantRoom> {
                existingInterpreterRoom
            })
            .ReturnsAsync(new List <ParticipantRoom> {
                existingInterpreterRoom, expectedJohRoom
            });

            _mocker.Mock <ICommandHandler>().Setup(x =>
                                                   x.Handle(It.IsAny <CreateParticipantRoomCommand>())).Callback <CreateParticipantRoomCommand>(command =>
            {
                command.SetProtectedProperty(nameof(command.NewRoomId), expectedRoomId);
            });

            _mocker.Mock <ICommandHandler>().Setup(x =>
                                                   x.Handle(It.IsAny <UpdateParticipantRoomConnectionDetailsCommand>())).Callback(() =>
                                                                                                                                  expectedJohRoom.UpdateConnectionDetails(newVmrRoom.Room_label, null, newVmrRoom.Uris.Pexip_node,
                                                                                                                                                                          newVmrRoom.Uris.Participant));

            _mocker.Mock <IKinlyApiClient>().Setup(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(),
                                                                                     It.Is <CreateParticipantRoomParams>(vmrRequest => vmrRequest.Room_type == KinlyRoomType.Panel_Member)))
            .ReturnsAsync(newVmrRoom);

            // act
            var room = await _service.GetOrCreateAJudicialVirtualRoom(_conference, joh);

            // assert
            room.Should().NotBeNull();
            room.Label.Should().Be(newVmrRoom.Room_label);
            room.PexipNode.Should().Be(newVmrRoom.Uris.Pexip_node);
            room.ParticipantUri.Should().Be(newVmrRoom.Uris.Participant);

            _mocker.Mock <IKinlyApiClient>().Verify(x => x.CreateParticipantRoomAsync(_conference.Id.ToString(),
                                                                                      It.Is <CreateParticipantRoomParams>(createParams =>
                                                                                                                          createParams.Room_label_prefix == "Panel Member" &&
                                                                                                                          createParams.Participant_type == "Civilian" &&
                                                                                                                          createParams.Room_type == KinlyRoomType.Panel_Member &&
                                                                                                                          createParams.Participant_room_id == expectedRoomId.ToString() &&
                                                                                                                          createParams.Audio_recording_url == string.Empty
                                                                                                                          )), Times.Once);
        }