public async Task should_update_room_with_new_details()
        {
            var seededConference = await TestDataManager.SeedConference();

            _newConferenceId = seededConference.Id;
            var room = new ParticipantRoom(_newConferenceId, VirtualCourtRoomType.Civilian);
            await TestDataManager.SeedRooms(new [] { room });

            var label     = "Interpreter1";
            var ingestUrl = "dummyurl";
            var node      = "node";
            var uri       = "fakeuri";
            var command   = new UpdateParticipantRoomConnectionDetailsCommand(_newConferenceId, room.Id, label, ingestUrl, node, uri);
            await _handler.Handle(command);

            var roomId = command.RoomId;

            await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions);
            var updatedRoom = await db.Rooms.OfType <ParticipantRoom>().AsNoTracking()
                              .SingleAsync(c => c.Id == roomId);

            updatedRoom.Label.Should().Be(label);
            updatedRoom.IngestUrl.Should().Be(ingestUrl);
            updatedRoom.PexipNode.Should().Be(node);
            updatedRoom.ParticipantUri.Should().Be(uri);
        }
        public async Task should_add_participant_to_interpreter_room()
        {
            var conference = await TestDataManager.SeedConference();

            _newConferenceId = conference.Id;
            var interpreterRoom = new ParticipantRoom(_newConferenceId, "InterpreterRoom1", VirtualCourtRoomType.Witness);
            var rooms           = await TestDataManager.SeedRooms(new[] { interpreterRoom });

            interpreterRoom = (ParticipantRoom)rooms[0];
            var participant = conference.Participants.First(x => x.UserRole == UserRole.Individual);

            var command = new AddParticipantToParticipantRoomCommand(interpreterRoom.Id, participant.Id);
            await _handler.Handle(command);

            await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions);
            var updatedRoom = await db.Rooms.OfType <ParticipantRoom>().AsNoTracking()
                              .Include(r => r.RoomParticipants)
                              .SingleAsync(r => r.Id == interpreterRoom.Id);

            updatedRoom.RoomParticipants.Any(p => p.ParticipantId == participant.Id).Should().BeTrue();

            var updatedParticipantFromDb = await db.Participants.Include(x => x.RoomParticipants).ThenInclude(x => x.Room).AsNoTracking()
                                           .SingleAsync(p => p.Id == participant.Id);

            updatedParticipantFromDb.RoomParticipants.Any(r => r.RoomId == interpreterRoom.Id).Should().BeTrue();

            var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId));

            var updatedParticipant = updatedConference.Participants.First(x => x.Id == participant.Id);

            updatedParticipant.GetParticipantRoom().Should().NotBeNull();
            updatedParticipant.GetParticipantRoom().Id.Should().Be(interpreterRoom.Id);
        }
Ejemplo n.º 3
0
        public async Task should_return_list_of_interpreter_rooms_for_conference()
        {
            var conference = await TestDataManager.SeedConference();

            _newConferenceId = conference.Id;
            _rooms           = CreateRoomsForConference(conference.Id);
            await TestDataManager.SeedRooms(_rooms);

            var interpreterRooms = _rooms.Where(r => r is ParticipantRoom).ToList();

            var query  = new GetParticipantRoomsForConferenceQuery(conference.Id);
            var result = await _handler.Handle(query);


            result.Count.Should().Be(interpreterRooms.Count);
            result.Select(r => r.Id).Should().Contain(interpreterRooms.Select(r => r.Id));
        }
        private async Task SetupRoomWithParticipant(Conference conference)
        {
            var interpreterRoom = new ParticipantRoom(_newConferenceId, "InterpreterRoom1", VirtualCourtRoomType.Witness);
            var rooms           = await TestDataManager.SeedRooms(new[] { interpreterRoom });

            _room = (ParticipantRoom)rooms[0];
            var participant = conference.Participants.First(x => x.UserRole == UserRole.Individual);

            await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions);
            var room = await db.Rooms.OfType <ParticipantRoom>()
                       .Include(r => r.RoomParticipants)
                       .SingleAsync(r => r.Id == _room.Id);

            room.AddParticipant(new RoomParticipant(participant.Id));
            await db.SaveChangesAsync();

            _room = room;
        }
        public async Task Should_returns_room_with_status_live_or_created_for_the_given_room_type()
        {
            var seededConference = await TestDataManager.SeedConference();

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;
            var participant = seededConference.Participants.First(x => x.UserRole == UserRole.Judge);

            var listRooms = GetListRoom(_newConferenceId);
            var roomSaved = await TestDataManager.SeedRooms(listRooms);

            await TestDataManager.SeedRoomWithRoomParticipant(roomSaved[0].Id, new RoomParticipant(participant.Id));


            _expectedIds = new List <long> {
                roomSaved[1].Id, roomSaved[2].Id, roomSaved[3].Id
            };
            _notExpectedIds = new List <long> {
                roomSaved[0].Id, roomSaved[4].Id
            };

            await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions);

            var roomToUpdate = await db.Rooms.Include(x => x.RoomParticipants).SingleAsync(x => x.Id == roomSaved[0].Id);

            roomToUpdate.RemoveParticipant(new RoomParticipant(participant.Id));
            await db.SaveChangesAsync();

            var query  = new GetAvailableConsultationRoomsByRoomTypeQuery(VirtualCourtRoomType.JudgeJOH, _newConferenceId);
            var result = await _handler.Handle(query);

            result.Should().NotBeEmpty();
            result.Any(x => x.Id == _expectedIds[0]).Should().Be(true);
            result.Any(x => x.Id == _expectedIds[1]).Should().Be(true);
            result.Any(x => x.Id == _expectedIds[2]).Should().Be(true);
            result.Any(x => x.Id == _notExpectedIds[0]).Should().Be(false);
            result.Any(x => x.Id == _notExpectedIds[1]).Should().Be(false);
        }