Esempio n. 1
0
        public void ElementSameIgnoringChildren_MissingChildren_ShouldFail()
        {
            XElement root1 = XElement.Parse(@"<xmlns:Root a='1' b='2' xmlns='http://www.northwind.com' />");
            XElement root2 = XElement.Parse(@"<xmlns:Root b='2' a='1' xmlns='http://www.northwind.com'><xmlns:Child>1</xmlns:Child></xmlns:Root>");

            Assert.IsFalse(XmlCompare.ElementSameIgnoringChildren(root1, root2).AreSame);
        }
Esempio n. 2
0
        public void CompareAttributes_Same_ShouldSucceed()
        {
            XElement root1 = XElement.Parse(@"<Root a='1' b='2' xmlns='http://www.northwind.com'> <Child>1</Child></Root>");
            XElement root2 = XElement.Parse(@"<n:Root b='2' a='1' xmlns:n='http://www.northwind.com'><n:Child>1</n:Child></n:Root>");

            Assert.IsTrue(XmlCompare.CompareAttributes(root1, root2).AreSame);
        }
Esempio n. 3
0
        public void CompareAttributes_Missing_ShouldFail()
        {
            XElement root1 = XElement.Parse(@"<Root a='1' b='2' xmlns='http://www.northwind.com'> <Child>1</Child></Root>");
            XElement root2 = XElement.Parse(@"<n:Root xmlns:n='http://www.northwind.com'><n:Child>1</n:Child></n:Root>");

            Assert.IsFalse(XmlCompare.CompareAttributes(root1, root2).AreSame);
        }
Esempio n. 4
0
        public void CompareNames_Different_ShouldFail()
        {
            XElement root1 = XElement.Parse(@"<Root />");
            XElement root2 = XElement.Parse(@"<Root2 />");

            Assert.IsFalse(XmlCompare.CompareNames(root1, root2).AreSame);
        }
Esempio n. 5
0
        public void CompareNames_DifferentNameSpace_ShouldFail()
        {
            XElement root1 = XElement.Parse(@"<Root xmlns='http://www.northwind.com'> <Child>1</Child></Root>");
            XElement root2 = XElement.Parse(@"<n:Root xmlns:n='http://www.northwind2.com'><n:Child>1</n:Child></n:Root>");

            Assert.IsFalse(XmlCompare.CompareNames(root1, root2).AreSame);
        }
Esempio n. 6
0
        public void ElementSame_DifferentCountChildren_ShouldFail()
        {
            XElement root1 = XElement.Parse(@"<Root a='1' b='2' xmlns='http://www.northwind.com'> <Child>1</Child></Root>");
            XElement root2 = XElement.Parse(@"<n:Root b='2' a='1' xmlns:n='http://www.northwind.com'><n:Child>1</n:Child><n:Child /></n:Root>");

            Assert.IsFalse(XmlCompare.ElementSame(root1, root2).AreSame);
        }
Esempio n. 7
0
        public void ElementSameIgnoringChildren_ValuesMatch_ShouldSucceed()
        {
            XElement root1 = XElement.Parse(@"<Root a='1' b='2' xmlns='http://www.northwind.com'>2</Root>");
            XElement root2 = XElement.Parse(@"<n:Root b='2' a='1' xmlns:n='http://www.northwind.com'>2</n:Root>");

            Assert.IsTrue(XmlCompare.ElementSameIgnoringChildren(root1, root2).AreSame);
        }
Esempio n. 8
0
        public void CompareNames_Same_ShouldSucceed()
        {
            XElement root1 = XElement.Parse(@"<Root />");
            XElement root2 = XElement.Parse(@"<Root />");

            Assert.IsTrue(XmlCompare.CompareNames(root1, root2).AreSame);
        }
Esempio n. 9
0
        public void TestRoundTripParseOpfWithGuide()
        {
            XDocument doc  = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.contentWithImages.opf");
            var       opf  = new Opf(doc, "OEPBS/content.opf");
            var       doc2 = opf.ToXDocument();

            var delta = XmlCompare.ElementSame(doc.Root, doc2.Root);

            Assert.IsTrue(delta.AreSame);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public void RoundTripContainer()
        {
            XDocument doc       = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.container.xml");
            var       container = new Container(doc);

            Assert.AreEqual("OEBPS/content.opf", container.FullPath);
            var doc2  = container.ToXDocument();
            var delta = XmlCompare.ElementSame(doc.Root, doc2.Root);

            Assert.IsTrue(delta.AreSame);
        }
Esempio n. 12
0
        public void RoundTripMetadata(string resourceName)
        {
            XDocument doc       = Utils.ReadXmlResource(resourceName);
            var       element   = doc.Root.Element(Epub.PackageNs + "metadata");
            var       fakeItems = Utils.FakeItems(doc);
            var       metadata  = new Metadata(element, fakeItems);

            var element2 = metadata.ToXElement(fakeItems.Values.ToList());
            var delta    = XmlCompare.ElementSame(element, element2);

            Assert.IsTrue(delta.AreSame);
        }
Esempio n. 13
0
        public void TestRoundTripParseToCWithNesting()
        {
            XDocument doc         = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.tocWithNesting.ncx");
            var       mockNcxItem = new EpubItem()
            {
                AbsolutePath = "toc.ncx"
            };
            var api = Utils.FakeAbsolutePathIndex(doc, "toc.ncx");

            var toc   = new ToC(doc, mockNcxItem, api);
            var doc2  = toc.ToXDocument();
            var delta = XmlCompare.ElementSame(doc.Root, doc2.Root);

            Assert.IsTrue(delta.AreSame);
        }