Beispiel #1
0
        public void TestValidateXhtmlWitAgilityPack()
        {
            string xml    = Utils.ReadStringResource("UnitTestMergeWebToEpub.TestData.PrettyPrint.xhtml");
            var    actual = HtmlAgilityPackUtils.ValidateXhtmlWitAgilityPack(xml);

            Assert.AreEqual(0, actual.Count);
        }
Beispiel #2
0
        public void TestPrettyPrintCover()
        {
            string    xml         = Utils.ReadStringResource("UnitTestMergeWebToEpub.TestData.Cover.xhtml");
            var       fromAgility = HtmlAgilityPackUtils.PrettyPrintXhtml(xml);
            XDocument agilityDoc  = XDocument.Parse(fromAgility);
            XDocument doc         = doc = Encoding.UTF8.GetBytes(xml).ToXhtml();
            var       delta       = XmlCompare.ElementSame(agilityDoc.Root, doc.Root);

            Assert.IsTrue(delta.AreSame);
        }
Beispiel #3
0
 private bool TestPrettyPrint(Epub epub)
 {
     foreach (var item in epub.Opf.Spine)
     {
         XDocument doc         = item.RawBytes.ToXhtml();
         var       xml         = Encoding.UTF8.GetString(item.RawBytes);
         var       fromAgility = HtmlAgilityPackUtils.PrettyPrintXhtml(xml);
         XDocument agilityDoc  = Encoding.UTF8.GetBytes(fromAgility).ToXhtml();
         var       delta       = XmlCompare.ElementSame(agilityDoc.Root, doc.Root);
         if (!delta.AreSame)
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #4
0
        public void TestHtmlTextToXhtml()
        {
            var actual = HtmlAgilityPackUtils.HtmlTextToXhtml("Weekend at Uncle Discord's: Day One & Two");

            Assert.AreEqual("Weekend at Uncle Discord's: Day One & Two", actual);
        }