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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void InputIntoDetailAreaAsBelow(Table table)
        {
            try
            {
                Dictionary <string, InputElementType> elementType = new Dictionary <string, InputElementType>();
                elementType.Add("Pendenz Typ", InputElementType.Dropdown);
                //elementType.Add("Betreff", InputElementType.Textbox);
                elementType.Add("Beschreibung", InputElementType.Textarea);
                elementType.Add("Empfänger", InputElementType.GridDropdown);
                elementType.Add("Fällig", InputElementType.Datebox);

                Dictionary <string, string> screenMapping = new Dictionary <string, string>();
                screenMapping.Add("Pendenz Typ", "pendenzTyp");
                screenMapping.Add("Betreff", "betreff");
                screenMapping.Add("Beschreibung", "beschreibung");
                screenMapping.Add("Empfänger", "empfanger");
                screenMapping.Add("Fällig", "fallig");

                TestDataManager.InputTableData(new string[] { XPathPendenzen.TaskDetailFields1 }, table, elementType, screenMapping);
                Dictionary <string, string> fieldMapping = new Dictionary <string, string>();
                fieldMapping.Add("Betreff", "Subject");
                fieldMapping.Add("Beschreibung", "TaskDescription");
                fieldMapping.Add("Fällig", "ExpirationDate");

                TestDataManager.AddToTempEntities <XTask>(table, fieldMapping: fieldMapping);
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }
        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);
        }
Beispiel #5
0
        public async Task Should_retrieve_all_messages_for_the_participant()
        {
            var conference = new ConferenceBuilder(true)
                             .WithParticipant(UserRole.Individual, "Claimant")
                             .WithParticipant(UserRole.Judge, "Judge")
                             .Build();

            var judge       = conference.GetParticipants().First(x => x.UserRole == UserRole.Judge);
            var participant = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);
            var vhOfficer   = "VH Officer";

            conference.AddInstantMessage(vhOfficer, "InstantMessage 1", judge.DisplayName);
            conference.AddInstantMessage(judge.DisplayName, "InstantMessage 2", vhOfficer);

            conference.AddInstantMessage(participant.Username, "Hello VHO", vhOfficer);
            conference.AddInstantMessage(vhOfficer, "Hello ParticipantOne", participant.Username);

            var seededConference = await TestDataManager.SeedConference(conference);

            _newConferenceId = seededConference.Id;

            var query   = new GetInstantMessagesForConferenceQuery(_newConferenceId, participant.Username);
            var results = await _handler.Handle(query);

            results.Count.Should().Be(conference.GetInstantMessageHistoryFor(participant.Username).Count);
            results.Should().BeInDescendingOrder(x => x.TimeStamp);
        }
        public async Task Should_get_non_closed_conference()
        {
            var knownHearingRefId = Guid.NewGuid();
            var conference1       = new ConferenceBuilder(true, knownHearingRefId)
                                    .WithParticipant(UserRole.Representative, "Defendant")
                                    .WithParticipant(UserRole.Judge, null)
                                    .WithConferenceStatus(ConferenceState.Closed)
                                    .Build();

            _newConferenceId1 = conference1.Id;

            var conference2 = new ConferenceBuilder(true, knownHearingRefId)
                              .WithParticipant(UserRole.Representative, "Defendant")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.InSession)
                              .Build();

            _newConferenceId2 = conference2.Id;

            await TestDataManager.SeedConference(conference1);

            await TestDataManager.SeedConference(conference2);

            var conference = await _handler.Handle(new GetNonClosedConferenceByHearingRefIdQuery(knownHearingRefId));

            AssertConference(conference, conference2, true);
        }
        public async Task Should_update_participant_username_when_provided()
        {
            var seededConference = await TestDataManager.SeedConference();

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

            var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName",
                                                              "lastName", "displayname", String.Empty, "*****@*****.**", "0123456789", new List <LinkedParticipantDto>())
            {
                Username = "******"
            };
            await _handler.Handle(command);

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

            var updatedParticipant =
                updatedConference.GetParticipants().Single(x => x.Id == participant.Id);

            updatedParticipant.DisplayName.Should().Be("displayname");
            updatedParticipant.Name.Should().Be("fullname");
            updatedParticipant.FirstName.Should().Be("firstName");
            updatedParticipant.LastName.Should().Be("lastName");
            updatedParticipant.ContactEmail.Should().Be("*****@*****.**");
            updatedParticipant.ContactTelephone.Should().Be("0123456789");
            updatedParticipant.Username.Should().Be(command.Username);
        }
Beispiel #8
0
        public async Task Should_return_conferences_still_open_after_14_hours()
        {
            var utcDate         = DateTime.UtcNow;
            var expired         = utcDate.AddHours(-15);
            var withinTimeLimit = utcDate.AddHours(-10);
            var beyondTimeLimit = utcDate.AddHours(10);

            var conference1 = new ConferenceBuilder(true, scheduledDateTime: expired)
                              .WithParticipant(UserRole.Representative, "Respondent")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.InSession)
                              .Build();

            _conference1Id = conference1.Id;

            var conference2 = new ConferenceBuilder(true, scheduledDateTime: withinTimeLimit)
                              .WithParticipant(UserRole.Representative, "Respondent")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.InSession)
                              .Build();

            _conference2Id = conference2.Id;

            var conference3 = new ConferenceBuilder(true, scheduledDateTime: beyondTimeLimit)
                              .WithParticipant(UserRole.Representative, "Respondent")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.Paused)
                              .Build();

            _conference3Id = conference3.Id;

            var conference4 = new ConferenceBuilder(true, scheduledDateTime: expired)
                              .WithParticipant(UserRole.Representative, "Respondent")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.Closed)
                              .Build();

            _conference4Id = conference4.Id;

            await TestDataManager.SeedConference(conference1);

            await TestDataManager.SeedConference(conference2);

            await TestDataManager.SeedConference(conference3);

            await TestDataManager.SeedConference(conference4);

            var conferences = await _handler.Handle(new GetExpiredUnclosedConferencesQuery());

            var confIds = conferences.Select(x => x.Id).ToList();

            confIds.Should().Contain(conference1.Id);

            var notExpectedConferences = new List <Guid> {
                conference2.Id, conference3.Id, conference4.Id
            };

            confIds.Should()
            .NotContain(notExpectedConferences);
        }
Beispiel #9
0
        /// <summary>
        /// 评测此JudgeTask
        /// </summary>
        private void Judge(JudgeTask task)
        {
            ITaskSubmitter submitter = FetcherFactory.CreateTaskSubmitter();

            try
            {
                // 检查测试数据是否为最新
                if (!TestDataManager.CheckData(task.ProblemID, task.DataVersion))
                {
                    ITestDataFetcher fetcher = FetcherFactory.CreateTestDataFetcher();
                    TestDataManager.WriteTestData(task.ProblemID, fetcher.Fetch(task.ProblemID));
                }

                JudgeResult result;
                using (MainJudger judger = new MainJudger(task))
                {
                    result = judger.Judge();
                }

                submitter.Submit(result);
            }
            catch (Exception ex)//判题失败
            {
                submitter.Submit(CreateFailedJudgeResult(task, ex.ToString()));
                throw ex;
            }
        }
Beispiel #10
0
        public async Task Should_add_participant_to_conference()
        {
            var seededConference = await TestDataManager.SeedConference();

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

            var participant  = new ParticipantBuilder(true).Build();
            var participants = new List <Participant>()
            {
                participant
            };
            var command = new AddParticipantsToConferenceCommand(_newConferenceId, participants, new List <LinkedParticipantDto>());

            await _handler.Handle(command);

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

            var confParticipants = conference.GetParticipants();

            confParticipants.Any(x => x.Username == participant.Username).Should().BeTrue();
            var afterCount = conference.GetParticipants().Count;

            afterCount.Should().BeGreaterThan(beforeCount);
        }
        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);
        }
        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);
        }
        /// <summary>
        /// 构建并写出供Judger使用的SPJ程序
        /// </summary>
        private void BuildSpecialJudgeProgram()
        {
            File.WriteAllText(
                Path.Combine(SpjContext.TempDirectory, SpjLangConfig.SourceCodeFileName),
                SpjTask.SourceCode);

            if (!LangConfig.NeedCompile)
            {
                return;
            }

            // 构建SPJ程序
            if (TestDataManager.GetSpecialJudgeProgramFile(JudgeTask.ProblemId) == null)
            {
                if (!CompileSpecialJudgeProgram())
                {
                    throw new CompileException("Can not build special judge program!");
                }
            }

            SpecialJudgeProgram spjProgram = TestDataManager.GetSpecialJudgeProgramFile(JudgeTask.ProblemId);

            File.WriteAllBytes(
                Path.Combine(SpjContext.TempDirectory, spjProgram.LangConfiguration.ProgramFileName),
                spjProgram.Program);
        }
Beispiel #14
0
        public void WhenCallAPICreateUpdateTaskInCreatePendenzenWithInputDataAsBelow(Table table)
        {
            try
            {
                Dictionary <string, string> idFieldMapping = new Dictionary <string, string>();
                idFieldMapping.Add("empfangerId", "UserID");
                idFieldMapping.Add("falltrager", "BaPersonID");
                idFieldMapping.Add("leistung", "FaLeistungID");
                idFieldMapping.Add("PersonId", "BaPersonID");
                var insertCondition = TestDataManager.CreateSetWithLookup <CreateUpdateQuery>(table, idFieldMapping: idFieldMapping).First();
                TestDataManager.CallApiPostReturnObject <CreateUpdateQuery, bool>(Url.CreateUpdateTask, insertCondition);

                Dictionary <string, string> fieldMapping = new Dictionary <string, string>();
                fieldMapping.Add("status", "TaskStatusCode");
                fieldMapping.Add("pendenzTyp", "TaskTypeCode");
                fieldMapping.Add("betreff", "Subject");
                fieldMapping.Add("beschreibung", "TaskDescription");
                fieldMapping.Add("empfangerId", "ReceiverID");
                fieldMapping.Add("falltrager", "FaFallID");
                fieldMapping.Add("leistung", "FaLeistungID");
                fieldMapping.Add("PersonId", "BaPersonID");
                fieldMapping.Add("antwort", "ResponseText");
                Dictionary <string, string> xtaskIdFieldMapping = new Dictionary <string, string>();
                xtaskIdFieldMapping.Add("SenderID", "UserID");
                xtaskIdFieldMapping.Add("ReceiverID", "UserID");
                xtaskIdFieldMapping.Add("FaFallID", "BaPersonID");
                TestDataManager.AddToTempEntities <XTask>(table, fieldMapping: fieldMapping, idFieldMapping: xtaskIdFieldMapping);
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }
Beispiel #15
0
        public void Replace_ReplacedAndEventRaised()
        {
            TestDataManager dm = new TestDataManager();
            TestDataType    data1 = new TestDataType {
                Id = 1U
            }, data2 = new TestDataType {
                Id = 2U
            };

            dm.Add(data1);

            TestDataObserver obs = new TestDataObserver();

            using IDisposable unsubscriber = dm.Subscribe(obs);
            Assert.AreEqual(dm.Get(1U), data1);
            dm.ReplaceData(new HashSet <TestDataType> {
                data2
            });
            Assert.AreEqual(dm.Get(2U), data2);
            Assert.AreEqual(0, obs.CompleteCount);
            Assert.AreEqual(0, obs.Errors.Count);
            Assert.AreEqual(1, obs.Next.Count);
            DataChanged <TestDataType> change = obs.Next.Dequeue();

            Assert.IsTrue(change.Action == DataChangedAction.Replace &&
                          change.OldItems?.FirstOrDefault() == data1 &&
                          change.NewItems?.FirstOrDefault() == data2);
        }
        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);
        }
        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 TestInit()
 {
     var tdm = new TestDataManager<KLibDBTestEntities>(Assembly.GetExecutingAssembly(),
                                                                "Scripts");
     tdm.RunScript("Clear.sql");
     tdm.RunScript("Init.sql");
 }
        public IntegrationTest(ITestOutputHelper output)
        {
            lock (SyncLock)
            {
                if (!Inited)
                {
                    _databaseManager = new DatabaseManager();
                    _databaseManager.CreateEmptyDatabase();
                    _databaseManager.InitSchema();
                    if (SchemaUpdater != null)
                    {
                        using (var connection = _databaseManager.OpenConnection())
                        {
                            SchemaUpdater(connection);
                        }
                    }

                    DeleteOldTestDatabases();

                    Inited = true;
                }
            }

            _testDataManager = new TestDataManager(_databaseManager.OpenConnection)
            {
                TestUser = new TestUser
                {
                    Email    = "*****@*****.**",
                    Password = "******",
                    Username = "******"
                }
            };
        }
Beispiel #20
0
        public async Task Should_get_list_of_judges_excluding_anonymised_and_automation_test_users()
        {
            var newConference = new ConferenceBuilder(true)
                                .WithParticipant(UserRole.Judge, "Judge", "*****@*****.**", "JudgeManchester", null, ParticipantState.None)
                                .WithParticipant(UserRole.Representative, "Applicant", "*****@*****.**", "Applicant", null, ParticipantState.None)
                                .WithParticipant(UserRole.Individual, "Applicant", "*****@*****.**", "Applicant", null, ParticipantState.None)
                                .Build();

            _conferenceIds.Add(newConference.Id);
            await TestDataManager.SeedConference(newConference);

            // anonymised data
            newConference = new ConferenceBuilder(true)
                            .WithParticipant(UserRole.Judge, "Judge", "[email protected]", "JudgeLondon", null, ParticipantState.None)
                            .WithParticipant(UserRole.Representative, "Applicant", "*****@*****.**", "Applicant", null, ParticipantState.None)
                            .WithParticipant(UserRole.Individual, "Applicant", "*****@*****.**", "Applicant", null, ParticipantState.None)
                            .Build();
            _conferenceIds.Add(newConference.Id);
            await TestDataManager.SeedConference(newConference);

            var judgeList = await _handler.Handle(new GetDistinctJudgeListByFirstNameQuery());

            judgeList.Should().NotBeEmpty();
            judgeList.Should().NotContain("JudgeLondon");
        }
Beispiel #21
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);
        }
Beispiel #22
0
        public void InputIntoSearchAreaAsBelow(Table table)
        {
            try
            {
                string[] xPaths = new string[]
                {
                    XPathPendenzen.SearchFields3,
                    XPathPendenzen.SearchFields2,
                    XPathPendenzen.SearchFields1
                };

                Dictionary <string, InputElementType> elementType = new Dictionary <string, InputElementType>();
                elementType.Add("Status", InputElementType.Dropdown);
                //elementType.Add("Betreff", InputElementType.Textbox);
                elementType.Add("Bearbeitung from", InputElementType.Datebox);
                elementType.Add("Bearbeitung to", InputElementType.Datebox);
                elementType.Add("Ersteller", InputElementType.GridDropdown);

                Dictionary <string, string> screenMapping = new Dictionary <string, string>();
                screenMapping.Add("Status", "status");
                screenMapping.Add("Betreff", "betreff");
                screenMapping.Add("Bearbeitung from", "processing-box-item1");
                screenMapping.Add("Bearbeitung to", "processing-box-item3");
                screenMapping.Add("Ersteller", "creator");

                TestDataManager.InputTableData(xPaths, table, elementType, screenMapping);
                TestDataManager.Click(XPathPendenzen.PageHeaderLeft, waitingTime: 2);
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }
Beispiel #23
0
        /// <summary>
        /// 编译SPJ程序
        /// </summary>
        /// <returns>是否编译并写出成功</returns>
        private bool CompileSpecialJudgeProgram()
        {
            Compiler compiler      = new Compiler(SpjContext);
            string   compileResult = compiler.Compile();

            if (compileResult != "")
            {
                throw new CompileException("Can not compile special judge program!" + Environment.NewLine +
                                           compileResult);
            }

            string spjProgramPath =
                Path.Combine(SpjContext.TempDirectory, LangConfig.ProgramFileName);

            if (!File.Exists(spjProgramPath))
            {
                throw new CompileException("Special judge program not found!");
            }

            SpecialJudgeProgram spjProgram = new SpecialJudgeProgram
            {
                LangConfiguration = LangConfig,
                Program           = File.ReadAllBytes(spjProgramPath)
            };

            TestDataManager.WriteSpecialJudgeProgramFile(JudgeTask.ProblemId, spjProgram);

            return(TestDataManager.GetSpecialJudgeProgramFile(JudgeTask.ProblemId) != null);
        }
Beispiel #24
0
        public void ContentOfTreeLeftNavMenuShouldBe(Table table)
        {
            Dictionary <string, string> xPaths = new Dictionary <string, string>();

            xPaths.Add(XPathPendenzen.NavbarItems, null);

            Dictionary <string, string> screenMapping = new Dictionary <string, string>();

            screenMapping.Add("Meine Pendenzen/fällige", "1_1");
            screenMapping.Add("Meine Pendenzen/offene", "1_2");
            screenMapping.Add("Meine Pendenzen/in Bearbeitung", "1_3");
            screenMapping.Add("Meine Pendenzen/selber erstellte", "1_4");
            screenMapping.Add("Meine Pendenzen/erhaltene", "1_5");
            screenMapping.Add("Meine Pendenzen/zu visierende", "1_6");
            screenMapping.Add("Erstellte Pendenzen/fällige", "2_1");
            screenMapping.Add("Erstellte Pendenzen/offene", "2_2");
            screenMapping.Add("Erstellte Pendenzen/allgemeine", "2_3");
            screenMapping.Add("Erstellte Pendenzen/zu visierende", "2_4");
            try
            {
                TestDataManager.CheckTableData(xPaths, table, screenMapping: screenMapping);
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }
Beispiel #25
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 async Task TearDown()
 {
     if (_newConferenceId != Guid.Empty)
     {
         await TestDataManager.RemoveRooms(_newConferenceId);
     }
 }
Beispiel #27
0
        public async Task Should_update_participant_status_and_virtual_room()
        {
            var seededConference = await TestDataManager.SeedConference();

            _newConferenceIds.Add(seededConference.Id);
            var consultationRoom = new ConsultationRoom(seededConference.Id, $"JudgeConsultationRoom{DateTime.UtcNow.Ticks}",
                                                        VirtualCourtRoomType.JudgeJOH, false);
            var seededRoom = await TestDataManager.SeedRoom(consultationRoom);

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            TestContext.WriteLine($"New seeded room id: {seededRoom.Id}");
            var participant = seededConference.GetParticipants().First(p => p.IsJudge());
            const ParticipantState state = ParticipantState.InConsultation;

            var beforeState = participant.GetCurrentStatus();

            var command = new UpdateParticipantStatusAndRoomCommand(seededConference.Id, participant.Id, state, null, seededRoom.Label);
            await _handler.Handle(command);

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

            var updatedParticipant = updatedConference.GetParticipants().Single(x => x.Username == participant.Username);
            var afterState         = updatedParticipant.GetCurrentStatus();

            afterState.Should().NotBe(beforeState);
            afterState.ParticipantState.Should().Be(state);
            updatedParticipant.CurrentRoom.Should().BeNull();
            updatedParticipant.CurrentConsultationRoom.Label.Should().Be(seededRoom.Label);
        }
Beispiel #28
0
        static WebTest()
        {
            var mapper = new AssemblyScanningMappingProvider();

            mapper.Scan(typeof(AccountRepository).Assembly);
            EntityMappingProvider.Provider = mapper;

            _databaseManager.CreateEmptyDatabase();
            _databaseManager.InitSchema();

            AppDomain.CurrentDomain.DomainUnload += (o, e) =>
            {
                _iisExpress?.Stop();
                _databaseManager.Dispose();
            };

            // Disables database migration in codeRR.Server.Web project, should be up-to-date already
            // SchemaUpdateModule does not handle coderr_ConnectionString environment variable
            // This should only be run on build server due to changes in web.config
            if (Environment.GetEnvironmentVariable("TF_BUILD") != null)
            {
                DisableDatabaseMigrations();
            }

            var configPath =
                Path.Combine(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\")),
                             "applicationhost.config");

            Console.WriteLine($"Path to IIS Express configuration file '{configPath}'");

            _iisExpress = new IisExpressHelper
            {
                ConfigPath = configPath,

                // Pass on connectionstring to codeRR.Server.Web during testing, overriding connectionstring in web.config
                EnvironmentVariables = new Dictionary <string, string> {
                    { "coderr_ConnectionString", _databaseManager.ConnectionString }
                }
            };
            _iisExpress.Start("codeRR.Server.Web");

            // Warmup request only on build server
            if (Environment.GetEnvironmentVariable("TF_BUILD") != null)
            {
                var webClient = new WebClient();
                webClient.DownloadString(_iisExpress.BaseUrl);
            }

            TestUser = new TestUser {
                Username = "******", Password = "******", Email = "*****@*****.**"
            };

            TestData = new TestDataManager(_databaseManager.OpenConnection)
            {
                TestUser = TestUser
            };

            WebDriver = DriverFactory.Create(BrowserType.Chrome);
            AppDomain.CurrentDomain.DomainUnload += (o, e) => { DisposeWebDriver(); };
        }
Beispiel #29
0
        public async Task should_update_participant_to_disconnected_from_virtual_room()
        {
            // Arrange conference with participant in consultation room
            var seededConference = await TestDataManager.SeedConference();

            _newConferenceIds.Add(seededConference.Id);
            var consultationRoom = new ConsultationRoom(seededConference.Id, $"JudgeConsultationRoom{DateTime.UtcNow.Ticks}",
                                                        VirtualCourtRoomType.JudgeJOH, false);

            var room = await TestDataManager.SeedRoom(consultationRoom);

            var newRoomId = room.Id;

            var pat1 = seededConference.Participants[0].Id;
            await TestDataManager.SeedRoomWithRoomParticipant(newRoomId, new RoomParticipant(pat1));

            // Act
            var command =
                new UpdateParticipantStatusAndRoomCommand(seededConference.Id, pat1, ParticipantState.Disconnected, null,
                                                          null);
            await _handler.Handle(command);

            // Assert
            var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(seededConference.Id));

            var updatedParticipant = updatedConference.GetParticipants().Single(x => x.Id == pat1);

            updatedParticipant.State.Should().Be(ParticipantState.Disconnected);
            updatedParticipant.CurrentRoom.Should().BeNull();
            updatedParticipant.CurrentConsultationRoom.Should().BeNull();
        }
Beispiel #30
0
        public async Task Should_not_anonymise_data_for_future_hearings()
        {
            conferenceList = new List <Domain.Conference>();
            var utcDate       = DateTime.UtcNow;
            var futureHearing = utcDate.AddMonths(1);

            var conference3 = new ConferenceBuilder(true, scheduledDateTime: futureHearing)
                              .WithParticipant(UserRole.Representative, "Respondent")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.InSession)
                              .Build();

            _conference3Id = conference3.Id;
            conferenceList.Add(conference3);
            var conference3Rep = conference3.Participants.FirstOrDefault(p => p.UserRole == UserRole.Representative);

            foreach (var c in conferenceList)
            {
                await TestDataManager.SeedConference(c);
            }
            var command = new AnonymiseConferencesCommand();
            await _handler.Handle(command);

            command.RecordsUpdated.Should().Be(-1);

            var conference = await _handlerGetConferenceByIdQueryHandler.Handle(new GetConferenceByIdQuery(conference3.Id));

            conference.Should().NotBeNull();

            conference.CaseName.Should().Be(conference3.CaseName);
            var representative = conference.Participants.FirstOrDefault(p => p.UserRole == UserRole.Representative);

            representative.DisplayName.Should().Be(conference3Rep.DisplayName);
        }
        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);
        }