示例#1
0
        public int TestTextReadInnerXml2()
        {
            bool   bPassed = false;
            String strExpected;

            if (IsXsltReader() || IsXmlNodeReaderDataDoc() || IsCoreReader() || IsXPathNavigatorReader())
            {
                strExpected = ST_EXPAND_ENTITIES2;
            }
            else
            {
                if (IsXmlNodeReader())
                {
                    strExpected = ST_EXPAND_ENTITIES3;
                }
                else
                {
                    strExpected = ST_EXPAND_ENTITIES3;
                }
            }

            ReloadSource();
            DataReader.PositionOnElement(ST_ENTTEST_NAME);

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);

            return(BoolToLTMResult(bPassed));
        }
示例#2
0
        public int XmlExceptionAndXmlTextReaderLineNumberShouldBeSameAfterExceptionIsThrown()
        {
            string filename = TestData + "Common/invalid-ucs4.xml";

            if (!IsCustomReader())
            {
                try
                {
                    ReloadSource(filename);
                    while (DataReader.Read())
                    {
                        ;
                    }
                    return(TEST_FAIL);
                }
                catch (XmlException e)
                {
                    CError.WriteLine(e.Message);
                    CError.WriteLine("Reader Line : {0}, Exception Line {1}", DataReader.LineNumber, e.LinePosition);
                    CError.Equals(DataReader.LineNumber, IsSubtreeReader() ? 0 : e.LineNumber, "Reader line number and Exception line number must be same");

                    CError.WriteLine("Reader Position : {0}, Exception Position {1}", DataReader.LinePosition, e.LinePosition);
                    CError.Equals(DataReader.LinePosition, IsSubtreeReader() ? 0 : e.LinePosition, "Reader line position and Exception line position must be same");
                    return(TEST_PASS);
                }
            }
            return(TEST_PASS);
        }
示例#3
0
        public int TestReadValue_8()
        {
            string xml = @"<elem0>   123" + "\n" + @" <elem1>" + "\r" + @"123 
<elem2>
123  </elem2>" + "\r\n" + @"  123</elem1>          123           </elem0>";

            ReloadSource(new StringReader(xml));

            char[] chars       = new char[100];
            int    startPos    = 0;
            int    readSize    = 3;
            int    currentSize = 0;

            try
            {
                while (DataReader.Read())
                {
                    DataReader.Read();
                    if (DataReader.NodeType == XmlNodeType.Text || DataReader.NodeType == XmlNodeType.None)
                    {
                        continue;
                    }
                    CError.Equals(DataReader.Value.Contains("123"), "Value");
                    currentSize = DataReader.ReadValueChunk(chars, startPos, readSize);
                    CError.Equals(currentSize, 3, "size");
                    CError.Equals(DataReader.LineNumber, 0, "LineNumber");
                    CError.Equals(DataReader.LinePosition, 0, "LinePosition");
                }
            }
            catch (NotSupportedException e) { CError.WriteLine(e); }
            DataReader.Close();
            return(TEST_PASS);
        }
示例#4
0
        public int TestLinePos43()
        {
            string strXml = "<foo\n    attr1='bar'\n    attr2='foo'\n/>";

            ReloadSourceStr(strXml);
            if (!IsCustomReader())
            {
                DataReader.Read();
                CError.Equals(DataReader.LineNumber, 1, null);
                CError.Equals(DataReader.LinePosition, 2, null);

                DataReader.MoveToFirstAttribute();
                CError.Equals(DataReader.LineNumber, 2, null);
                CError.Equals(DataReader.LinePosition, 5, null);

                DataReader.MoveToNextAttribute();
                CError.Equals(DataReader.LineNumber, 3, null);
                CError.Equals(DataReader.LinePosition, 5, null);

                DataReader.Read();
                CError.Equals(DataReader.LineNumber, IsSubtreeReader() ? 0 : 4, null);
                CError.Equals(DataReader.LinePosition, IsSubtreeReader() ? 0 : 3, null);
            }
            return(TEST_PASS);
        }
示例#5
0
        //[Variation("ReadContentAsBinHex on an xmlns attribute", Param = "<foo xmlns='default'> <bar > id='1'/> </foo>")]
        //[Variation("ReadContentAsBinHex on an xmlns:k attribute", Param = "<k:foo xmlns:k='default'> <k:bar id='1'/> </k:foo>")]
        //[Variation("ReadContentAsBinHex on an xml:space attribute", Param = "<foo xml:space='default'> <bar > id='1'/> </foo>")]
        //[Variation("ReadContentAsBinHex on an xml:lang attribute", Param = "<foo xml:lang='default'> <bar > id='1'/> </foo>")]
        public int TestBinHex_34()
        {
            string xml = (string)CurVariation.Param;

            byte[] buffer = new byte[8];
            try
            {
                ReloadSource(new StringReader(xml));
                DataReader.Read();
                if (IsBinaryReader())
                {
                    DataReader.Read();
                }
                DataReader.MoveToAttribute(0);
                CError.Compare(DataReader.Value, "default", "value");
                CError.Equals(DataReader.ReadContentAsBinHex(buffer, 0, 8), 5, "size");
                CError.Equals(false, "No exception");
            }
            catch (XmlException) { return(TEST_PASS); }
            catch (NotSupportedException) { return(TEST_PASS); }
            finally
            {
                DataReader.Close();
            }
            return(TEST_FAIL);
        }
示例#6
0
        public int TestReadBinHex_36()
        {
            string xml = @"<elem0>   123" + "\n" + @" <elem1>" + "\r" + @"123 
<elem2>
123  </elem2>" + "\r\n" + @"  123</elem1>          123           </elem0>";

            ReloadSource(new StringReader(xml));
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }
            byte[] buffer      = new byte[3];
            int    startPos    = 0;
            int    readSize    = 3;
            int    currentSize = 0;

            DataReader.Read();
            while (DataReader.Read())
            {
                CError.Equals(DataReader.Value.Contains("123"), "Value");
                currentSize = DataReader.ReadContentAsBinHex(buffer, startPos, readSize);
                CError.Equals(currentSize, 1, "size");
                CError.Equals(buffer[0], (byte)18, "buffer");
                if (!(IsXPathNavigatorReader() || IsXmlNodeReader() || IsXmlNodeReaderDataDoc()))
                {
                    CError.WriteLine("LineNumber" + DataReader.LineNumber);
                    CError.WriteLine("LinePosition" + DataReader.LinePosition);
                }
            }
            DataReader.Close();
            return(TEST_PASS);
        }
示例#7
0
        public int TestReadInnerXml10()
        {
            bool   bPassed = false;
            string strExpected;

            if (IsXsltReader() || IsXmlNodeReaderDataDoc() || IsXmlValidatingReader() || IsCoreReader() || IsXPathNavigatorReader())
            {
                strExpected = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES4;
            }
            else if (IsXmlNodeReader())
            {
                strExpected = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES2;
            }
            else
            {
                strExpected = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES2;
            }

            string strExpectedAttValue = ST_ENT1_ATT_EXPAND_ENTITIES;

            if (IsXmlTextReader())
            {
                strExpectedAttValue = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES;
            }

            ReloadSource();
            DataReader.PositionOnElement(ST_ENTTEST_NAME);
            bPassed = DataReader.MoveToFirstAttribute();

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);

            VerifyNextNode(XmlNodeType.Attribute, "att1", strExpectedAttValue);

            return(BoolToLTMResult(bPassed));
        }
示例#8
0
        public int TestReadValue_5()
        {
            string xml = "<elem0>123<elem1>123<elem2>123</elem2>123</elem1>123</elem0>";

            ReloadSource(new StringReader(xml));

            char[] chars       = new char[100];
            int    startPos    = 0;
            int    readSize    = 3;
            int    currentSize = 0;

            while (DataReader.Read())
            {
                DataReader.Read();
                if (DataReader.NodeType == XmlNodeType.Text || DataReader.NodeType == XmlNodeType.None)
                {
                    continue;
                }
                currentSize = DataReader.ReadValueChunk(chars, startPos, readSize);
                CError.Equals(currentSize, 3, "size");
                CError.Equals(chars[0].ToString(), "1", "buffer1");
                CError.Equals(chars[1].ToString(), "2", "buffer2");
                CError.Equals(chars[2].ToString(), "3", "buffer3");
                CError.Equals(DataReader.LineNumber, 0, "LineNumber");
                CError.Equals(DataReader.LinePosition, 0, "LinePosition");
            }
            DataReader.Close();
            return(TEST_PASS);
        }
示例#9
0
 //[Variation("DecodeName with uppercase/lowercase")]
 public int v4()
 {
     CError.Equals(XmlConvert.EncodeName("_xFF71__xff71_"), "_x005F_xFF71__x005F_xff71_", "EncodeName");
     CError.Equals(XmlConvert.EncodeLocalName("_xFF71__xff71_"), "_x005F_xFF71__x005F_xff71_", "EncodeLocalName");
     CError.Equals(XmlConvert.EncodeNmToken("_xFF71__xff71_"), "_x005F_xFF71__x005F_xff71_", "EncodeNmToken");
     CError.Equals(XmlConvert.DecodeName("_xFF71__xff71_"), "\uFF71\uFF71", "DecodeName");
     return(TEST_PASS);
 }
示例#10
0
        public int v7()
        {
            CError.Equals(ReaderDelegate.Create(GetStream(), GetSettings(), GetParserContext()), true, "StreamOverload3");

            CError.Equals(ReaderDelegate.Create(GetTextReader(), GetSettings(), GetParserContext()), true, "TextOverload3");

            return(TEST_PASS);
        }
示例#11
0
        public int TestNormalization5()
        {
            bool bPassed = false;

            ReloadSource();
            DataReader.PositionOnElement(ST_ATTR_TEST_NAME);
            bPassed = CError.Equals(DataReader.GetAttribute("TAB"), ST_ATTR_EXP_STRING, CurVariation.Desc);
            return(BoolToLTMResult(bPassed));
        }
示例#12
0
        public int TestNormalization8()
        {
            bool bPassed = false;

            ReloadSource();
            DataReader.PositionOnElement("ENDOFLINE3");
            DataReader.Read();
            bPassed = CError.Equals(DataReader.Value, ST_ELEM_EXP_STRING, CurVariation.Desc);
            return(BoolToLTMResult(bPassed));
        }
示例#13
0
        public int TestNormalization4()
        {
            bool bPassed = false;

            ReloadSource();
            DataReader.PositionOnElement(ST_ATTR_TEST_NAME);

            // as far as the MS attribute is CDATA internal spaces are not compacted
            bPassed = CError.Equals(DataReader.GetAttribute("MS"), ST_ATTR_EXP_STRING_MS, CurVariation.Desc);
            return(BoolToLTMResult(bPassed));
        }
示例#14
0
        public int TestReadInnerXml4()
        {
            bool   bPassed     = false;
            String strExpected = "1234";

            ReloadSource();
            DataReader.PositionOnElement("NONEMPTY2");
            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);
            VerifyNextNode(XmlNodeType.Element, "ACT2", String.Empty);

            return(BoolToLTMResult(bPassed));
        }
示例#15
0
        public int v6()
        {
            CError.Equals(ReaderDelegate.Create(GetStream(), GetSettings(), (string)null), true, "StreamOverload2");
            CError.Equals(ReaderDelegate.Create(GetStream(), GetSettings(), (XmlParserContext)null), true, "StreamOverload2");

            CError.Equals(ReaderDelegate.Create(GetUrl(), GetSettings()), true, "URL Overload 1");
            CError.Equals(ReaderDelegate.Create(GetUrl(), GetSettings(), GetParserContext()), true, "URL Overload 2");

            CError.Equals(ReaderDelegate.Create(GetTextReader(), GetSettings(), (string)null), true, "TextReader Overload2");
            CError.Equals(ReaderDelegate.Create(GetTextReader(), GetSettings(), (XmlParserContext)null), true, "TextReader Overload2");

            CError.Equals(ReaderDelegate.Create(GetXmlReader(), GetSettings()), true, "XmlReader Overload1");
            return(TEST_PASS);
        }
示例#16
0
        public int v3()
        {
            CError.Equals(ReaderDelegate.Create(GetStream(), null, GetParserContext()), true, "StreamOverload2");
            CError.Equals(ReaderDelegate.Create(GetStream(), null), true, "StreamOverload3");

            CError.Equals(ReaderDelegate.Create(GetUrl(), null), true, "URL Overload 1");
            CError.Equals(ReaderDelegate.Create(GetUrl(), null, GetParserContext()), true, "URL Overload 2");

            CError.Equals(ReaderDelegate.Create(GetTextReader(), null, GetParserContext()), true, "TextReader Overload2");
            CError.Equals(ReaderDelegate.Create(GetTextReader(), null), true, "TextReader Overload3");

            CError.Equals(ReaderDelegate.Create(GetXmlReader(), null), true, "XmlReader Overload1");
            return(TEST_PASS);
        }
示例#17
0
        public int TestReadInnerXml9()
        {
            bool   bPassed     = false;
            String strExpected = "a1value";

            ReloadSource();
            DataReader.PositionOnElement("ATTRIBUTE2");
            bPassed = DataReader.MoveToFirstAttribute();

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);
            VerifyNextNode(XmlNodeType.Attribute, "a1", strExpected);

            return(BoolToLTMResult(bPassed));
        }
示例#18
0
        public int TestReadInnerXml5()
        {
            bool   bPassed = false;
            String strExpected;

            strExpected = "xxx<MARKUP />yyy";

            ReloadSource();
            DataReader.PositionOnElement("CHARS2");

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);
            VerifyNextNode(XmlNodeType.Element, "CHARS_ELEM1", String.Empty);

            return(BoolToLTMResult(bPassed));
        }
示例#19
0
        public int TestReadInnerXml6()
        {
            bool   bPassed = false;
            String strExpected;

            strExpected = "<ELEM1 /><ELEM2>xxx yyy</ELEM2><ELEM3 />";

            ReloadSource();
            DataReader.PositionOnElement("SKIP3");

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);
            VerifyNextNode(XmlNodeType.Element, "AFTERSKIP3", String.Empty);

            return(BoolToLTMResult(bPassed));
        }
示例#20
0
        public int TestReadInnerXml7()
        {
            bool   bPassed     = false;
            String strExpected = "<e1 a1='a1value' a2='a2value'><e2 a1='a1value' a2='a2value'><e3 a1='a1value' a2='a2value'>leave</e3></e2></e1>";

            strExpected = strExpected.Replace('\'', '"');

            ReloadSource();
            DataReader.PositionOnElement("CONTENT");

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);
            VerifyNextNode(XmlNodeType.Element, "TITLE", String.Empty);

            return(BoolToLTMResult(bPassed));
        }
示例#21
0
        public int v1()
        {
            CError.Equals(ReaderDelegate.Create((Stream)null), false, "Null Stream doesnt throw error1");
            CError.Equals(ReaderDelegate.Create((Stream)null, GetSettings(), GetBaseUri()), false, "Null Stream doesnt throw error2");
            CError.Equals(ReaderDelegate.Create((Stream)null, GetSettings()), false, "Null Stream doesnt throw error3");

            CError.Equals(ReaderDelegate.Create((string)null), false, "Null URL doesnt throw error1");
            CError.Equals(ReaderDelegate.Create((string)null, GetSettings()), false, "Null URL doesnt throw error2");
            CError.Equals(ReaderDelegate.Create((string)null, GetSettings(), GetParserContext()), false, "Null URL doesnt throw error3");

            CError.Equals(ReaderDelegate.Create((TextReader)null), false, "Null TextReader doesnt throw error1");
            CError.Equals(ReaderDelegate.Create((TextReader)null, GetSettings(), GetBaseUri()), false, "Null TextReader doesnt throw error2");
            CError.Equals(ReaderDelegate.Create((TextReader)null, GetSettings()), false, "Null TextReader doesnt throw error2");

            return(TEST_PASS);
        }
示例#22
0
        //[Variation("ReadValueChunk on an xmlns attribute", Param = "<foo xmlns='default'> <bar > id='1'/> </foo>")]
        //[Variation("ReadValueChunk on an xmlns:k attribute", Param = "<k:foo xmlns:k='default'> <k:bar id='1'/> </k:foo>")]
        //[Variation("ReadValueChunk on an xml:space attribute", Param = "<foo xml:space='default'> <bar > id='1'/> </foo>")]
        //[Variation("ReadValueChunk on an xml:lang attribute", Param = "<foo xml:lang='default'> <bar > id='1'/> </foo>")]
        public int TestReadValue_6()
        {
            string xml = (string)this.CurVariation.Param;

            ReloadSource(new StringReader(xml));
            char[] chars = new char[8];

            DataReader.Read();
            DataReader.MoveToAttribute(0);
            try
            {
                CError.Equals(DataReader.Value, "default", "value");
                CError.Equals(DataReader.ReadValueChunk(chars, 0, 8), 7, "size");
            }
            catch (NotSupportedException e) { CError.WriteLine(e); }
            DataReader.Close();
            return(TEST_PASS);
        }
示例#23
0
        public int TestLinePos41()
        {
            String strXml = "<ROOT><CHARS2>\nxxx<MARKUP/>yyy\n</CHARS2></ROOT>";

            ReloadSourceStr(strXml);
            if (!IsCustomReader())
            {
                DataReader.Read();
                DataReader.Read();

                CError.Equals(DataReader.LineNumber, 1, "ln1");
                CError.Equals(DataReader.LinePosition, 8, "lp1");

                DataReader.ReadInnerXml();
                CError.Equals(DataReader.LineNumber, 3, "ln2");
                CError.Equals(DataReader.LinePosition, 12, "lp2");
            }
            return(TEST_PASS);
        }
示例#24
0
        public int TestReadInnerXml8()
        {
            bool bPassed = false;

            String strExpected = ST_EXPAND_ENTITIES3;

            if (IsXsltReader() || IsXmlNodeReader() || IsXmlNodeReaderDataDoc() || IsXmlValidatingReader() || IsCoreReader() || IsXPathNavigatorReader())
            {
                strExpected = ST_EXPAND_ENTITIES2;
            }

            ReloadSource();
            DataReader.PositionOnElement(ST_ENTTEST_NAME);

            bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc);
            VerifyNextNode(XmlNodeType.Element, "ENTITY2", String.Empty);

            return(BoolToLTMResult(bPassed));
        }
示例#25
0
        public int TestLinePos42()
        {
            String strXml = "<foo>\n       fooooooo\n</foo>";

            ReloadSourceStr(strXml);
            if (!IsCustomReader())
            {
                DataReader.Read();
                CError.Equals(DataReader.LineNumber, 1, null);
                CError.Equals(DataReader.LinePosition, 2, null);

                DataReader.Read();
                CError.Equals(DataReader.LineNumber, 1, null);
                CError.Equals(DataReader.LinePosition, 6, null);

                DataReader.Read();
                CError.Equals(DataReader.LineNumber, 3, null);
                CError.Equals(DataReader.LinePosition, 3, null);
            }
            return(TEST_PASS);
        }