예제 #1
0
        public void ShouldPreserveCDATA()
        {
            string           xml = "<HTML><![CDATA[<img src=\"/_layouts/images/\">]]></HTML>";
            XIncludingReader xir = new XIncludingReader(new StringReader(xml));

            xir.Read();
            Assert.AreEqual("<HTML><![CDATA[<img src=\"/_layouts/images/\">]]></HTML>", xir.ReadOuterXml());
        }
예제 #2
0
        public void TwoFallbacks()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/twofallbacks.xml");

            while (xir.Read())
            {
                ;
            }
            xir.Close();
        }
예제 #3
0
        public void UnknownParseAttribute()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/unknownparseattr.xml");

            while (xir.Read())
            {
                ;
            }
            xir.Close();
        }
예제 #4
0
        public void FallbackNotChildOfInclude()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/fallbacknotchildinclude.xml");

            while (xir.Read())
            {
                ;
            }
            xir.Close();
        }
예제 #5
0
        public void IncludeChildOfInclude()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/includechildofinclude.xml");

            while (xir.Read())
            {
                ;
            }
            xir.Close();
        }
예제 #6
0
        public void NoHrefAndNoXPointerAttributes()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/nohref.xml");

            while (xir.Read())
            {
                ;
            }
            xir.Close();
        }
예제 #7
0
        public void NoBaseURITest()
        {
            StreamReader sr  = new StreamReader("../../XInclude/tests/document.xml");
            string       xml = sr.ReadToEnd();

            sr.Close();
            XIncludingReader xir = new XIncludingReader(new StringReader(xml));
            XmlTextWriter    w   = new XmlTextWriter(Console.Out);

            while (xir.Read())
            {
                ;
            }
        }
예제 #8
0
        public void GetAttributeTest()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/document.xml");

            while (xir.Read())
            {
                if (xir.NodeType == XmlNodeType.Element && xir.Name == "disclaimer")
                {
                    Assert.IsTrue(xir.AttributeCount == 1);
                    Assert.IsTrue(xir.GetAttribute(0).EndsWith("disclaimer.xml"));
                    Assert.IsTrue(xir[0].EndsWith("disclaimer.xml"));
                }
            }
        }
예제 #9
0
        public void DepthTest()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/document.xml");
            StringBuilder    sb  = new StringBuilder();

            while (xir.Read())
            {
                Console.WriteLine("{0} | {1} | {2} | {3}",
                                  xir.NodeType, xir.Name, xir.Value, xir.Depth);
                sb.Append(xir.Depth);
            }
            string expected = "00011211111111223221100";

            Assert.AreEqual(sb.ToString(), expected);
        }
예제 #10
0
        public void GetAttributeTest2()
        {
            XIncludingReader xir = new XIncludingReader("../../XInclude/tests/document2.xml");

            xir.MakeRelativeBaseUri = false;
            while (xir.Read())
            {
                if (xir.NodeType == XmlNodeType.Element && xir.Name == "disclaimer")
                {
                    Assert.IsTrue(xir.AttributeCount == 1);
                    Assert.IsTrue(xir.GetAttribute(0).EndsWith("tests/disclaimerWithXmlBase.xml"));
                    Assert.IsTrue(xir[0].EndsWith("tests/disclaimerWithXmlBase.xml"));
                }
            }
        }
예제 #11
0
        public void TestLineInfo()
        {
            XIncludingReader r        = new XIncludingReader("../../XInclude/tests/document.xml");
            IXmlLineInfo     lineInfo = ((IXmlLineInfo)r);

            Assert.IsTrue(lineInfo.HasLineInfo());
            r.Read();
            Assert.AreEqual(1, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(1, lineInfo.LineNumber);
            Assert.AreEqual(22, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(2, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(54, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(6, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(8, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(54, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(56, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(1, lineInfo.LineNumber);
            Assert.AreEqual(22, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(5, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(17, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(12, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(4, lineInfo.LineNumber);
            Assert.AreEqual(2, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(4, lineInfo.LineNumber);
            Assert.AreEqual(13, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(5, lineInfo.LineNumber);
            Assert.AreEqual(4, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(5, lineInfo.LineNumber);
            Assert.AreEqual(6, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(7, lineInfo.LineNumber);
            Assert.AreEqual(18, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(7, lineInfo.LineNumber);
            Assert.AreEqual(20, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(8, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(4, lineInfo.LineNumber);
            Assert.AreEqual(75, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(6, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(6, lineInfo.LineNumber);
            Assert.AreEqual(12, lineInfo.LinePosition);
        }