Exemplo n.º 1
0
        // creating in-memory database
        public DataContextTest()
        {
            var optionsBuilder = new DbContextOptionsBuilder<DataContext>();
            optionsBuilder.UseInMemoryDatabase(false);
            _dataContext = new DataContext(optionsBuilder.Options);
            TestDataSupplier = _dataContext;
            _dataContext.ResourceTable.AddRange(
                new Resource { Name = "Description", CultureName = "en-US", Value = "description, responsibilities" },
                new Resource { Name = "EMail", CultureName = "en-US", Value = "mailto" },
                new Resource { Name = "Location", CultureName = "en-US", Value = "location, Israel, Tel Aviv" },
                new Resource { Name = "Requirements", CultureName = "en-US", Value = "requirements, required, skills, experience, degree, bachelor, advantage, mandatory" },
                new Resource { Name = "vacancyPageTitle", CultureName = "en-US", Value = "work, job, career, vacancy, vacancies" },
                new Resource { Name = "vacancyPageTitle", CultureName = "he-IL", Value = "דרושים, משרות, קריירה" },
                new Resource { Name = "vacancySubjectItem", CultureName = "en-US", Value = "developer, programmer, DBA, director, manager" });

            TestDataSupplier.Pages.Add(PageDocumentTestHelper.GetTestPage(3));
            TestDataSupplier.Save();
            _page = TestDataSupplier.Pages.Get().First();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads a page into the document
        /// </summary>
        /// <param name="page">an html page to load</param>
        protected void Load(Page page)
        {
            PageElements.Clear();
            _htmlDocument.clear();
            _page = page;
            _htmlDocument.write(page.Content);
            _htmlDocument.close();

            #if TESTING
            // if there is no message queue, mshtml cannot process DOM, so we just wait for our timeout to elapse
            Task.WaitAny(new [] {
                Task.Run(() => { while (_htmlDocument.readyState != "complete") Task.Delay(100); }) }, Timeout);
            #else
            if (Task.WaitAny(new[]
                { Task.Run(() => { while (_htmlDocument.readyState != "complete") Task.Delay(100); }) }, Timeout) == -1)
                throw new TimeoutException("Document preparation timeout expired.");
            #endif

            // set up an hierarchical element tree (skip not interesting tags such as DOCTYPE, xml, html and header)
            // this also creates all children
            AddAllPageElements(new MsHtmlPageElement(this, _htmlDocument.body, null));
        }