public async Task Should_update_existing_endpoint_with_new_status_and_room()
        {
            var conference1 = new ConferenceBuilder()
                              .WithEndpoint("DisplayName", "*****@*****.**").Build();
            var seededConference = await TestDataManager.SeedConference(conference1);

            var endpointId             = conference1.Endpoints.First().Id;
            const EndpointState status = EndpointState.Connected;
            const RoomType      room   = RoomType.HearingRoom;

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;

            var command = new UpdateEndpointStatusAndRoomCommand(_newConferenceId, endpointId, status, room);
            await _handler.Handle(command);

            Conference updatedConference;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                updatedConference = await db.Conferences.Include(x => x.Endpoints)
                                    .AsNoTracking().SingleOrDefaultAsync(x => x.Id == _newConferenceId);
            }
            var updatedEndpoint = updatedConference.GetEndpoints().Single(x => x.Id == endpointId);

            updatedEndpoint.State.Should().Be(status);
            updatedEndpoint.GetCurrentRoom().Should().Be(room);
        }
Ejemplo n.º 2
0
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler         = new GetInstantMessagesForConferenceQueryHandler(context);
            _newConferenceId = Guid.Empty;
        }
Ejemplo n.º 3
0
        public async Task Should_add_an_task(TaskType taskType)
        {
            var seededConference = await TestDataManager.SeedConference();

            _newConferenceId = seededConference.Id;
            const string body = "Automated Test Add Task";

            var command = CreateTaskCommand(seededConference, body, taskType);
            await _handler.Handle(command);

            List <Domain.Task> tasks;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                tasks = await db.Tasks.Where(x => x.ConferenceId == command.ConferenceId).ToListAsync();
            }

            var savedAlert = tasks.First(x => x.Body == body && x.Type == taskType);

            savedAlert.Should().NotBeNull();
            savedAlert.Status.Should().Be(TaskStatus.ToDo);
            savedAlert.Updated.Should().BeNull();
            savedAlert.UpdatedBy.Should().BeNull();
            savedAlert.ConferenceId.Should().Be(command.ConferenceId);
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler         = new UpdateEndpointStatusAndRoomCommandHandler(context);
            _newConferenceId = Guid.Empty;
        }
Ejemplo n.º 5
0
 public void Setup()
 {
     _context          = new VideoApiDbContext(VideoBookingsDbContextOptions);
     _handler          = new GetHeartbeatsFromTimePointQueryHandler(_context);
     _newConferenceId  = Guid.Empty;
     _newParticipantId = Guid.Empty;
 }
Ejemplo n.º 6
0
        public async Task should_add_endpoint_to_conference()
        {
            var seededConference = await TestDataManager.SeedConference();

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;

            var displayName     = "display1";
            var sip             = "*****@*****.**";
            var pin             = "123";
            var defenceAdvocate = "Defence Sol";

            var command = new AddEndpointCommand(_newConferenceId, displayName, sip, pin, defenceAdvocate);
            await _handler.Handle(command);

            Conference updatedConference;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                updatedConference = await db.Conferences.Include(x => x.Endpoints).SingleOrDefaultAsync(x => x.Id == _newConferenceId);
            }

            updatedConference.GetEndpoints().Should().NotBeEmpty();
            var ep = updatedConference.Endpoints.First();

            ep.Pin.Should().Be(pin);
            ep.SipAddress.Should().Be(sip);
            ep.DisplayName.Should().Be(displayName);
            ep.Id.Should().NotBeEmpty();
            ep.DefenceAdvocate.Should().Be(defenceAdvocate);
            ep.State.Should().Be(EndpointState.NotYetJoined);
        }
        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);
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler = new AddParticipantToParticipantRoomCommandHandler(context);
            _conferenceByIdHandler = new GetConferenceByIdQueryHandler(context);
        }
        public async Task Should_add_a_message()
        {
            var seededConference = await TestDataManager.SeedConference();

            _newConferenceId = seededConference.Id;

            var participants = seededConference.Participants;
            var from         = participants.First(x => x.UserRole == UserRole.Judge).DisplayName;
            var messageText  = Internet.DomainWord();
            var to           = "VH Officer";

            var command = new AddInstantMessageCommand(_newConferenceId, from, messageText, to);
            await _handler.Handle(command);

            List <InstantMessage> instantMessages;

            using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                instantMessages = await db.InstantMessages
                                  .Where(x => x.ConferenceId == command.ConferenceId).ToListAsync();
            }

            var message = instantMessages.First();

            message.Should().NotBeNull();
            message.From.Should().Be(from);
            message.MessageText.Should().Be(messageText);
            message.TimeStamp.Should().BeBefore(DateTime.UtcNow);
            message.ConferenceId.Should().Be(command.ConferenceId);
            message.To.Should().Be(to);
        }
Ejemplo n.º 10
0
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler       = new GetDistinctJudgeListByFirstNameQueryHandler(context);
            _conferenceIds = new List <Guid>();
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler         = new GetConferenceByIdQueryHandler(context);
            _newConferenceId = Guid.Empty;
        }
        public async Task Should_remove_messages_for_conference()
        {
            var conference = new ConferenceBuilder(true)
                             .WithMessages(2)
                             .Build();

            var seededConference = await TestDataManager.SeedConference(conference);

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;

            var command = new RemoveInstantMessagesForConferenceCommand(_newConferenceId);
            await _handler.Handle(command);

            List <InstantMessage> messages;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                messages = await db.InstantMessages.Where(x => x.ConferenceId == command.ConferenceId).ToListAsync();
            }

            var afterCount = messages.Count;

            afterCount.Should().Be(0);
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler         = new CreateConferenceCommandHandler(context);
            _newConferenceId = Guid.Empty;
        }
Ejemplo n.º 14
0
        public async Task Should_update_status_to_done(TaskType taskType)
        {
            const string body      = "Automated Test Complete Task";
            const string updatedBy = "*****@*****.**";

            _newConferenceId = Guid.NewGuid();
            var task = new Alert(_newConferenceId, _newConferenceId, body, taskType);
            await TestDataManager.SeedAlerts(new List <Alert> {
                task
            });

            var command = new UpdateTaskCommand(_newConferenceId, task.Id, updatedBy);
            await _handler.Handle(command);

            List <Alert> alerts;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                alerts = await db.Tasks.Where(x => x.ConferenceId == command.ConferenceId).ToListAsync();
            }

            var updatedAlert = alerts.First(x => x.Id == task.Id);

            updatedAlert.Should().NotBeNull();
            updatedAlert.Status.Should().Be(TaskStatus.Done);
            updatedAlert.Updated.Should().NotBeNull();
            updatedAlert.UpdatedBy.Should().Be(updatedBy);
        }
        public void Setup()
        {
            _newConferenceId = Guid.Empty;
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler = new GetAvailableConsultationRoomsByRoomTypeQueryHandler(context);
        }
 private async Task <ParticipantRoom> GetInterpreterRoom()
 {
     await using var db = new VideoApiDbContext(VideoBookingsDbContextOptions);
     return(await db.Rooms.OfType <ParticipantRoom>()
            .Include(r => r.RoomParticipants)
            .SingleAsync(r => r.Id == _room.Id));
 }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler         = new UpdateSelfTestCallResultCommandHandler(context);
            _newConferenceId = Guid.Empty;
        }
        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);
        }
Ejemplo n.º 19
0
        public void OneTimeSetup()
        {
            var configRootBuilder = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json")
                                    .AddEnvironmentVariables()
                                    .AddUserSecrets <Startup>();

            var configRoot = configRootBuilder.Build();

            _databaseConnectionString = configRoot.GetConnectionString("VhVideoApi");
            _services = Options.Create(configRoot.GetSection("Services").Get <ServicesConfiguration>()).Value;

            var dbContextOptionsBuilder = new DbContextOptionsBuilder <VideoApiDbContext>();

            dbContextOptionsBuilder.EnableSensitiveDataLogging();
            dbContextOptionsBuilder.UseSqlServer(_databaseConnectionString);
            dbContextOptionsBuilder.EnableSensitiveDataLogging();
            VideoBookingsDbContextOptions = dbContextOptionsBuilder.Options;

            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            context.Database.Migrate();

            TestDataManager = new TestDataManager(_services, VideoBookingsDbContextOptions);
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler         = new UpdateParticipantRoomConnectionDetailsCommandHandler(context);
            _newConferenceId = Guid.Empty;
        }
        public async Task Should_update_existing_endpoint_with_defence_advocate()
        {
            var conference1 = new ConferenceBuilder()
                              .WithEndpoint("DisplayName", "*****@*****.**").Build();
            var seededConference = await TestDataManager.SeedConference(conference1);

            var ep              = conference1.Endpoints.First();
            var sipAddress      = ep.SipAddress;
            var defenceAdvocate = "Sol Defence";

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;

            var command = new UpdateEndpointCommand(_newConferenceId, sipAddress, null, defenceAdvocate);
            await _handler.Handle(command);

            Conference updatedConference;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                updatedConference = await db.Conferences.Include(x => x.Endpoints)
                                    .AsNoTracking().SingleAsync(x => x.Id == _newConferenceId);
            }

            var updatedEndpoint = updatedConference.GetEndpoints().Single(x => x.SipAddress == sipAddress);

            updatedEndpoint.DisplayName.Should().Be(ep.DisplayName);
            updatedEndpoint.DefenceAdvocate.Should().Be(defenceAdvocate);
        }
Ejemplo n.º 22
0
        private async Task <LeaveConsultationRequest> SetupLeaveConsultationRequest(bool inConsultationRoom)
        {
            var request = new LeaveConsultationRequest
            {
                ConferenceId  = _context.Test.Conference.Id,
                ParticipantId = _context.Test.Conference.Participants[0].Id
            };

            if (!inConsultationRoom)
            {
                return(request);
            }

            var participantId = _context.Test.Conference.Participants[0].Id;

            await using (var db = new VideoApiDbContext(_context.VideoBookingsDbContextOptions))
            {
                var conference = await db.Conferences
                                 .Include("Participants")
                                 .SingleAsync(x => x.Id == _context.Test.Conference.Id);

                var room        = new ConsultationRoom(_context.Test.Conference.Id, "TestRoom", VirtualCourtRoomType.Participant, false);
                var participant = conference.Participants.Single(x => x.Id == participantId);
                participant.UpdateCurrentRoom(RoomType.ConsultationRoom);
                participant.UpdateCurrentConsultationRoom(room);

                await db.SaveChangesAsync();

                request.ParticipantId = participantId;
            }

            return(request);
        }
Ejemplo n.º 23
0
        public async Task SeedHeartbeats(IEnumerable <Heartbeat> heartbeats)
        {
            await using var db = new VideoApiDbContext(_dbContextOptions);
            await db.Heartbeats.AddRangeAsync(heartbeats);

            await db.SaveChangesAsync();
        }
Ejemplo n.º 24
0
        public async Task RemoveAlerts(Guid conferenceId)
        {
            await using var db = new VideoApiDbContext(_dbContextOptions);
            var toDelete = db.Tasks.Where(x => x.ConferenceId == conferenceId);

            db.Tasks.RemoveRange(toDelete);
            await db.SaveChangesAsync();
        }
Ejemplo n.º 25
0
        public async Task RemoveHeartbeats(Guid conferenceId, Guid participantId)
        {
            await using var db = new VideoApiDbContext(_dbContextOptions);
            var toDelete = db.Heartbeats.Where(x => x.ConferenceId == conferenceId && x.ParticipantId == participantId);

            db.Heartbeats.RemoveRange(toDelete);
            await db.SaveChangesAsync();
        }
Ejemplo n.º 26
0
        public void Setup()
        {
            _newConferenceId = Guid.Empty;
            _rooms           = null;
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler = new GetParticipantRoomsForConferenceQueryHandler(context);
        }
Ejemplo n.º 27
0
        public async Task RemoveEvents()
        {
            await using var db = new VideoApiDbContext(_dbContextOptions);
            var eventsToDelete = db.Events.Where(x => x.Reason.StartsWith("Automated"));

            db.Events.RemoveRange(eventsToDelete);
            await db.SaveChangesAsync();
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler = new RemoveParticipantsFromConferenceCommandHandler(context);
            _conferenceByIdHandler = new GetConferenceByIdQueryHandler(context);
            _newConferenceId       = Guid.Empty;
        }
Ejemplo n.º 29
0
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler = new UpdateConferenceDetailsCommandHandler(context);
            _conferenceByIdHandler = new GetConferenceByIdQueryHandler(context);
            _conferenceId          = Guid.Empty;
        }
        public void Setup()
        {
            var context = new VideoApiDbContext(VideoBookingsDbContextOptions);

            _handler          = new GetNonClosedConferenceByHearingRefIdQueryHandler(context);
            _newConferenceId1 = Guid.Empty;
            _newConferenceId2 = Guid.Empty;
        }