Пример #1
0
        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);
        }
Пример #2
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());
        }