Esempio n. 1
0
        public async Task should_remove_a_participant_in_room()
        {
            var participant      = TestConference.Participants[0];
            var consultationRoom = new ConsultationRoom(TestConference.Id, "ConsultationRoom2", VirtualCourtRoomType.Participant, false);

            consultationRoom.AddParticipant(new RoomParticipant(participant.Id));
            _queryHandler.Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(consultationRoom);
            var participantId = participant.Id;
            var fromRoom      = consultationRoom.Label;
            var toRoom        = "WaitingRoom";

            _queryHandler.Setup(x => x.Handle <GetConferenceByIdQuery, Conference>(It.IsAny <GetConferenceByIdQuery>()))
            .ReturnsAsync(TestConference);

            await _consultationService.LeaveConsultationAsync(TestConference.Id, participantId, fromRoom, toRoom);

            _kinlyApiClient.Verify(x =>
                                   x.TransferParticipantAsync(TestConference.Id.ToString(),
                                                              It.Is <TransferParticipantParams>(r =>
                                                                                                r.From == fromRoom &&
                                                                                                r.To == toRoom
                                                                                                )
                                                              )
                                   , Times.Exactly(1));
        }
Esempio n. 2
0
        public async Task should_transfer_linked_participant_out_of_consultation_when_last_non_linked_participant_leaves_consultation()
        {
            // arrange
            var conference = new ConferenceBuilder()
                             .WithParticipant(UserRole.Judge, null)
                             .WithParticipant(UserRole.Individual, "Applicant")
                             .WithLinkedParticipant(UserRole.Individual, "Applicant")
                             .WithInterpreterRoom()
                             .Build();

            var interpreterRoom  = conference.Rooms.OfType <ParticipantRoom>().First();
            var participant      = conference.Participants.First(x => !x.IsJudge() && x.GetParticipantRoom() == null);
            var consultationRoom = new ConsultationRoom(conference.Id, "ConsultationRoom2", VirtualCourtRoomType.Participant, false);

            foreach (var p in conference.Participants.Where(x => !x.IsJudge()))
            {
                consultationRoom.AddParticipant(new RoomParticipant(p.Id));
            }

            _mocker.Mock <IQueryHandler>().Setup(x => x.Handle <GetConferenceByIdQuery, Conference>(
                                                     It.Is <GetConferenceByIdQuery>(q => q.ConferenceId == conference.Id)))
            .ReturnsAsync(conference);

            _mocker.Mock <IQueryHandler>().Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(consultationRoom);

            // act
            await _sut.LeaveConsultationAsync(conference.Id, participant.Id, consultationRoom.Label,
                                              RoomType.WaitingRoom.ToString());

            // assert
            _mocker.Mock <IKinlyApiClient>().Verify(x =>
                                                    x.TransferParticipantAsync(conference.Id.ToString(),
                                                                               It.Is <TransferParticipantParams>(r =>
                                                                                                                 r.From == consultationRoom.Label &&
                                                                                                                 r.To == RoomType.WaitingRoom.ToString() &&
                                                                                                                 r.Part_id == participant.Id.ToString())
                                                                               )
                                                    , Times.Once);

            _mocker.Mock <IKinlyApiClient>().Verify(x =>
                                                    x.TransferParticipantAsync(conference.Id.ToString(),
                                                                               It.Is <TransferParticipantParams>(r =>
                                                                                                                 r.From == consultationRoom.Label &&
                                                                                                                 r.To == RoomType.WaitingRoom.ToString() &&
                                                                                                                 r.Part_id == interpreterRoom.Id.ToString())
                                                                               )
                                                    , Times.Once);
        }