コード例 #1
0
ファイル: ReadToDescendant.cs プロジェクト: yang73137/corefx
        public int v2_1()
        {
            ManagedNodeWriter mnw = new ManagedNodeWriter();

            mnw.PutPattern("X");

            int count = 0;

            do
            {
                mnw.PutPattern("E/");
                count++;
            } while (count < 65536);
            mnw.PutText("<a/>");
            mnw.Finish();

            ReloadSource(new StringReader(mnw.GetNodes()));
            DataReader.PositionOnElement("ELEMENT_1");

            CError.WriteLine("Reading to : a");
            DataReader.ReadToDescendant("a");

            CError.Compare(DataReader.Depth, 65536, "Depth is not correct");
            CError.Compare(DataReader.NodeType, XmlNodeType.Element, "Nodetype is not correct");

            while (DataReader.Read())
            {
                ;
            }
            DataReader.Close();

            return(TEST_PASS);
        }
コード例 #2
0
ファイル: FilterSettings.cs プロジェクト: yang73137/corefx
        public int w03()
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern("WXEAA/M");
            CError.WriteLineIgnore(mn.GetNodes());
            XmlReaderSettings rs     = new XmlReaderSettings();
            XmlReader         reader = null;

            rs.IgnoreComments = true;
            reader            = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);
            bool thrown = false;

            try
            {
                CheckIgnores(reader, true, false, false);
            }
            catch (XmlException xe)
            {
                CError.WriteLineIgnore(xe.Message);
                thrown = true;
            }

            if (!thrown)
            {
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
コード例 #3
0
ファイル: ReadSubTree.cs プロジェクト: layomia/dotnet_runtime
        public int v100()
        {
            ManagedNodeWriter mnw = new ManagedNodeWriter();

            mnw.PutPattern("X");
            do
            {
                mnw.OpenElement();
                mnw.CloseElement();
            }while (mnw.GetNodes().Length < 4096);

            mnw.Finish();

            ReloadSource(new StringReader(mnw.GetNodes()));

            DataReader.PositionOnElement("ELEMENT_2");

            XmlReader r = DataReader.ReadSubtree();

            while (r.Read())
            {
                ;
            }

            DataReader.Read();

            CError.Compare(DataReader.Name, "ELEMENT_1", "Main name doesn't match");
            CError.Compare(DataReader.Value, "", "Main value doesn't match");
            CError.Compare(DataReader.NodeType.ToString().ToUpperInvariant(), "ENDELEMENT", "Main nodetype doesn't match");

            DataReader.Close();
            return(TEST_PASS);
        }
コード例 #4
0
ファイル: FilterSettings.cs プロジェクト: yang73137/corefx
        public int w02()
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern("XEA");
            mn.PutAttribute("xml:space", "preserve");
            mn.PutPattern("/PWPWE/WCCCCPPPee");

            CError.WriteLineIgnore(mn.GetNodes());
            XmlReaderSettings rs     = new XmlReaderSettings();
            XmlReader         reader = null;

            rs.IgnoreWhitespace = true;

            reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);
            CheckIgnores(reader, true, false, false);
            if (_wsCount != 3)
            {
                CError.WriteLineIgnore("Ws = " + _wsCount);
                return(TEST_FAIL);
            }

            rs.IgnoreWhitespace = false;
            reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);
            CheckIgnores(reader, false, false, false);
            if (_wsCount != 3)
            {
                CError.WriteLineIgnore("Ws = " + _wsCount);
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
コード例 #5
0
ファイル: FilterSettings.cs プロジェクト: yang73137/corefx
        public int w01()
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern("XWEAWA/PWWPWWE/WWCCCCPPPee");
            CError.WriteLineIgnore(mn.GetNodes());
            XmlReaderSettings rs     = new XmlReaderSettings();
            XmlReader         reader = null;

            rs.IgnoreWhitespace = true;
            reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);
            if (!CheckIgnores(reader, false, false, true))
            {
                return(TEST_FAIL);
            }

            rs.IgnoreWhitespace = false;
            reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);
            if (!CheckIgnores(reader, false, false, false))
            {
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
コード例 #6
0
        public string GetPatternXml(string pattern)
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern(pattern);
            CError.WriteLine("'" + mn.GetNodes() + "'");
            return(mn.GetNodes());
        }
コード例 #7
0
        public string GetSimpleInvalidXml()
        {
            string            invalidCharString = StringGen.GetIllegalXmlString(10, true);
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutDecl();
            mn.OpenElement("&#xd800;");
            mn.CloseElement();
            mn.PutText(invalidCharString);
            mn.PutEndElement();
            return(mn.GetNodes());
        }
コード例 #8
0
ファイル: FilterSettings.cs プロジェクト: yang73137/corefx
        public int pi03()
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern("XEEAA/MTe");
            CError.WriteLineIgnore(mn.GetNodes());
            XmlReaderSettings rs     = new XmlReaderSettings();
            XmlReader         reader = null;

            rs.IgnoreProcessingInstructions = true;
            reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);
            reader.Read();

            CError.Compare(reader.NodeType, XmlNodeType.XmlDeclaration, "XmlDecl should not be ignored");

            return(TEST_PASS);
        }
コード例 #9
0
        //[Variation("Default Reader, Check Characters On and pass invalid characters in text", Pri = 0, Params = new object[] { "CoreValidatingReader" })]
        //[Variation("Default Reader, Check Characters On and pass invalid characters in text", Pri = 0, Params = new object[] { "CoreReader" })]
        public int v5()
        {
            string readerType      = (string)this.CurVariation.Params[0];
            bool   exceptionThrown = false;

            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutDecl();
            mn.OpenElement();
            mn.CloseElement();
            mn.PutText("&#xd800;"); //This is invalid char in XML.
            mn.PutEndElement();
            string invalidCharXml = mn.GetNodes();

            XmlReaderSettings rs = new XmlReaderSettings();

            rs.CheckCharacters = true;

            XmlReader reader = ReaderHelper.CreateReader(readerType, new StringReader(invalidCharXml), false, null, rs);

            try
            {
                while (reader.Read())
                {
                    ;
                }
            }
            catch (XmlException xe)
            {
                CError.WriteIgnore(invalidCharXml);
                CError.WriteLine(xe.Message);
                CError.WriteLine(xe.StackTrace);
                exceptionThrown = true;
            }

            mn.Close();
            reader.Dispose();

            if (!exceptionThrown)
            {
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
コード例 #10
0
        //[Variation("Default Reader, Check Characters Off and pass invalid characters in element", Pri = 0, Params = new object[] { "CoreValidatingReader" })]
        //[Variation("Default Reader, Check Characters Off and pass invalid characters in element", Pri = 0, Params = new object[] {"CoreReader"})]
        public int v4()
        {
            string readerType      = (string)this.CurVariation.Params[0];
            bool   exceptionThrown = false;

            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutDecl();
            mn.OpenElement("&#xd800;");
            mn.CloseEmptyElement();

            XmlReaderSettings rs = new XmlReaderSettings();

            rs.CheckCharacters = false;
            XmlReader reader = ReaderHelper.CreateReader(readerType, new StringReader(mn.GetNodes()), false, null, rs);

            try
            {
                while (reader.Read())
                {
                    ;
                }
            }
            catch (XmlException xe)
            {
                CError.WriteIgnore(xe.Message + "\n");
                exceptionThrown = true;
            }

            mn.Close();
            reader.Dispose();

            if (!exceptionThrown)
            {
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
コード例 #11
0
        public int v2_1()
        {
            ManagedNodeWriter mnw = new ManagedNodeWriter();

            mnw.PutPattern("X");

            int count = 0;

            do
            {
                mnw.PutPattern("E/");
                count++;
            } while (count < 65536);
            mnw.PutText("<a/><b/>");
            mnw.Finish();

            CError.WriteIgnore(mnw.GetNodes() + "\n");

            ReloadSource(new StringReader(mnw.GetNodes()));
            DataReader.PositionOnElement("ELEMENT_0");

            CError.Compare(DataReader.ReadToDescendant("a"), "Couldnt go to Descendant");
            int depth = DataReader.Depth;

            CError.Compare(DataReader.ReadToNextSibling("b"), "Couldnt go to NextSibling");


            CError.Compare(DataReader.Depth, depth, "Depth is not correct");
            CError.Compare(DataReader.NodeType, XmlNodeType.Element, "Nodetype is not correct");

            while (DataReader.Read())
            {
                ;
            }
            DataReader.Close();

            return(TEST_PASS);
        }
コード例 #12
0
ファイル: FilterSettings.cs プロジェクト: yang73137/corefx
        public int c03()
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern("XE/");
            mn.PutText("--&gt;");
            mn.PutPattern("e");

            CError.WriteLineIgnore(mn.GetNodes());
            XmlReaderSettings rs     = new XmlReaderSettings();
            XmlReader         reader = null;

            rs.IgnoreComments = true;
            reader            = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);

            while (reader.Read())
            {
                ;
            }
            reader.Dispose();

            return(TEST_PASS);
        }
コード例 #13
0
        public object[] GetAllPri0ConformanceTestXmlStrings()
        {
            /*
             * The following XML Strings will be created :
             *
             * 1 Text at Top Level
             * 2 More than one element at top level
             * 3 WhiteSpace at Top level
             * 4 Top Level Attribute
             * 5 Multiple Contiguous Text Nodes.
             * 6 Same Prefix declared twice.
             * 7 xml:space contains wrong value
             * 8 Invalid Name for element
             * 9 Invalid Name for attribute
             * 10 Prefix Xml matched with wrong namespace URI.
             * 11 prefix Xml missing Namepace URI
             * 12 prefix or localname xmlns matches with wrong namespace URI
             * 13 prefix or localname xmlns missing namespace uri.
             *
             */

            List <string>     list = new List <string>();
            ManagedNodeWriter mn   = null;

            list.Add(GetPatternXml("T"));     //1
            list.Add(GetPatternXml("XEMEM")); //2
            list.Add(GetPatternXml("WEM"));   //3
            list.Add(GetPatternXml("TPT"));   //4
            list.Add(GetPatternXml("A"));     //5

            //6
            mn = new ManagedNodeWriter();
            mn.PutPattern("XE");
            mn.PutAttribute("xmlns:a", "http://www.foo.com");
            mn.PutAttribute("xmlns:a", "http://www.foo.com");
            mn.PutPattern("M");
            CError.WriteLine(mn.GetNodes());
            list.Add(mn.GetNodes());
            mn.Close();

            //7
            mn = new ManagedNodeWriter();
            mn.PutPattern("XE");
            mn.PutAttribute("xml:space", "rubbish");
            mn.PutPattern("M");
            CError.WriteLine(mn.GetNodes());
            list.Add(mn.GetNodes());
            mn.Close();

            //8
            mn = new ManagedNodeWriter();
            mn.PutPattern("X");
            mn.OpenElement(UnicodeCharHelper.GetInvalidCharacters(CharType.XmlChar));
            mn.PutPattern("M");
            CError.WriteLine(mn.GetNodes());
            list.Add(mn.GetNodes());
            mn.Close();

            //9
            mn = new ManagedNodeWriter();
            mn.PutPattern("XE");
            mn.PutAttribute(UnicodeCharHelper.GetInvalidCharacters(CharType.XmlChar), UnicodeCharHelper.GetInvalidCharacters(CharType.XmlChar));
            mn.PutPattern("M");
            CError.WriteLine(mn.GetNodes());
            list.Add(mn.GetNodes());
            mn.Close();

            //10
            mn = new ManagedNodeWriter();
            mn.PutPattern("XE");
            mn.PutAttribute("xmlns:xml", "http://wrong");
            mn.PutPattern("M");
            CError.WriteLine(mn.GetNodes());
            list.Add(mn.GetNodes());
            mn.Close();

            //11
            mn = new ManagedNodeWriter();
            mn.PutPattern("XE");
            mn.PutAttribute("xml:space", "default");
            mn.PutPattern("M");
            CError.WriteLine(mn.GetNodes());
            list.Add(mn.GetNodes());
            mn.Close();

            return(list.ToArray());
        }