public void CopyEntireDom()
        {
            string html = Support2.GetFile(TestDomPath("HTML Standard"));

            var    dom     = CQ.Create(html);
            string output  = dom.Render();
            var    dom2    = CQ.Create(output);
            string output2 = dom2.Render();

            Assert.AreEqual(output, output2, "There's no entropy in reparsing a rendered domain.");
            Debug.Write("HTML5 spec parsing: original was " + html.Length + " bytes. CSQ output was " + output.Length);
        }
Beispiel #2
0
        public void InsertingContent()
        {
            var dom        = TestDom("TestHtml");
            var totalCount = dom["*"].Length;

            string newHtml = Support2.GetFile(TestDomPath("TestHtml"));

            //change it slightly to force the string refs to be offset

            newHtml = newHtml.Insert(newHtml.IndexOf("<body>") + 6, "<div id=\"new-div\">Johnny Come Lately</div>");
            var dom2 = CQ.Create(newHtml);

            Assert.AreEqual(totalCount + 1, dom2["*"].Length, "The new copy was the same as the original");

            var addingCount = dom2["body *"].Length;

            dom2["body"].Children().InsertBefore(dom["#hlinks-user"].Children().First());
            Assert.AreEqual(totalCount + addingCount, dom["*"].Length, "The combined DOM is the right length");

            dom["#hlinks-user .reputation-score"].Clone().AppendTo("body");
            Assert.AreEqual("3,215", dom[".reputation-score"].First().Text(), "Text didn't get mangled on multiple moves (bug 11/11/11)");
            Assert.AreEqual("3,215", dom[".reputation-score"].Last().Text(), "Text didn't get mangled on multiple moves (bug 11/11/11)");
        }
Beispiel #3
0
 protected string TestHtml(string name)
 {
     return(Support2.GetFile(TestDomPath(name)));
 }