Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #4
0
        public void CompareNames_Different_ShouldFail()
        {
            XElement root1 = XElement.Parse(@"<Root />");
            XElement root2 = XElement.Parse(@"<Root2 />");

            Assert.IsFalse(XmlCompare.CompareNames(root1, root2).AreSame);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #8
0
        public void CompareNames_Same_ShouldSucceed()
        {
            XElement root1 = XElement.Parse(@"<Root />");
            XElement root2 = XElement.Parse(@"<Root />");

            Assert.IsTrue(XmlCompare.CompareNames(root1, root2).AreSame);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }