public async Task Should_not_transfer_endpoints_out_of_room_when_last_participant_leaves_if_transferring_to_hearing()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);
            var room = new ConsultationRoom(conference.Id, "ConsultationRoom2", VirtualCourtRoomType.Participant, false);

            room.AddEndpoint(new RoomEndpoint(Guid.NewGuid()));
            room.AddEndpoint(new RoomEndpoint(Guid.NewGuid()));
            QueryHandlerMock.Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(room);

            var callbackEvent = new CallbackEvent
            {
                EventType                = EventType.Transfer,
                EventId                  = Guid.NewGuid().ToString(),
                ConferenceId             = conference.Id,
                ParticipantId            = participantForEvent.Id,
                TransferFrom             = null,
                TransferTo               = RoomType.HearingRoom,
                TransferredFromRoomLabel = "ConsultationRoom2",
                TransferredToRoomLabel   = RoomType.HearingRoom.ToString(),
                TimeStampUtc             = DateTime.UtcNow
            };
            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.InHearing &&
                                                                            command.Room == RoomType.HearingRoom &&
                                                                            command.RoomLabel == RoomType.HearingRoom.ToString())), Times.Once);

            _mocker.Mock <IConsultationService>().Verify(x => x.EndpointTransferToRoomAsync(conference.Id, It.IsAny <Guid>(), RoomType.WaitingRoom.ToString()), Times.Never);
        }
        public void Should_not_add_existing_endpoint_to_room_twice()
        {
            var endpointId   = Guid.NewGuid();
            var roomEndpoint = new RoomEndpoint(endpointId);
            var room         = new ConsultationRoom(Guid.NewGuid(), "Room1", VirtualCourtRoomType.Participant, false);

            room.AddEndpoint(roomEndpoint);
            var beforeCount = room.RoomEndpoints.Count;

            room.AddEndpoint(roomEndpoint);

            room.RoomEndpoints.Count.Should().Be(beforeCount);
        }
Example #3
0
        public async Task should_return_bad_request_when_endpoint_is_already_in_room()
        {
            var endpointWithDefenceAdvocate = TestConference.GetEndpoints().First(x => !string.IsNullOrWhiteSpace(x.DefenceAdvocate));
            var defenceAdvocate             = TestConference.GetParticipants().First(x =>
                                                                                     x.Username.Equals(endpointWithDefenceAdvocate.DefenceAdvocate,
                                                                                                       StringComparison.CurrentCultureIgnoreCase));

            var room = new ConsultationRoom(TestConference.Id, "Label", VideoApi.Domain.Enums.VirtualCourtRoomType.Participant, false);

            room.AddEndpoint(new RoomEndpoint(Guid.NewGuid()));
            QueryHandlerMock.Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(room);

            var request = new EndpointConsultationRequest()
            {
                ConferenceId  = TestConference.Id,
                EndpointId    = endpointWithDefenceAdvocate.Id,
                RequestedById = defenceAdvocate.Id,
                RoomLabel     = "Label"
            };
            var result = await Controller.StartConsultationWithEndpointAsync(request);

            var actionResult = result.As <BadRequestObjectResult>();

            actionResult.Should().NotBeNull();
            actionResult.Value.Should().Be("Room already has an active endpoint");
        }
        public void Should_add_endpoint_to_room()
        {
            var endpointId   = Guid.NewGuid();
            var roomEndpoint = new RoomEndpoint(endpointId);
            var room         = new ConsultationRoom(Guid.NewGuid(), "Room1", VirtualCourtRoomType.Participant, false);

            room.AddEndpoint(roomEndpoint);

            room.RoomEndpoints.Count.Should().Be(1);
            room.RoomEndpoints[0].EndpointId.Should().Be(endpointId);
        }
        public void Should_remove_endpoint_from_room()
        {
            var endpointId   = Guid.NewGuid();
            var roomEndpoint = new RoomEndpoint(endpointId);
            var room         = new ConsultationRoom(Guid.NewGuid(), "Room1", VirtualCourtRoomType.Participant, false);

            room.AddEndpoint(roomEndpoint);
            var beforeCount = room.RoomEndpoints.Count;

            room.RemoveEndpoint(roomEndpoint);

            room.RoomEndpoints.Count.Should().Be(beforeCount - 1);
        }
        public async Task Should_transfer_endpoints_out_of_room_when_defense_advocate_participant_leaves_and_room_not_empty()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Representative && x.Username == "*****@*****.**");
            var room = new ConsultationRoom(conference.Id, "ConsultationRoom2", VirtualCourtRoomType.Participant, false);

            room.AddParticipant(new RoomParticipant(Guid.NewGuid()));
            room.AddParticipant(new RoomParticipant(Guid.NewGuid()));
            foreach (var endpoint in conference.GetEndpoints())
            {
                room.AddEndpoint(new RoomEndpoint(endpoint.Id));
            }

            QueryHandlerMock.Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(room);

            var callbackEvent = new CallbackEvent
            {
                EventType                = EventType.Transfer,
                EventId                  = Guid.NewGuid().ToString(),
                ConferenceId             = conference.Id,
                ParticipantId            = participantForEvent.Id,
                TransferFrom             = null,
                TransferTo               = RoomType.WaitingRoom,
                TransferredFromRoomLabel = "ConsultationRoom2",
                TransferredToRoomLabel   = RoomType.WaitingRoom.ToString(),
                TimeStampUtc             = DateTime.UtcNow
            };
            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.Available &&
                                                                            command.Room == RoomType.WaitingRoom &&
                                                                            command.RoomLabel == RoomType.WaitingRoom.ToString())), Times.Once);

            _mocker.Mock <IConsultationService>().Verify(x => x.EndpointTransferToRoomAsync(conference.Id, It.IsAny <Guid>(), RoomType.WaitingRoom.ToString()), Times.Once);
        }