public string GetSimpleInvalidXml() { string invalidCharString = StringGen.GetIllegalXmlString(10, true); ManagedNodeWriter mn = new ManagedNodeWriter(); mn.PutDecl(); mn.OpenElement("�"); mn.CloseElement(); mn.PutText(invalidCharString); mn.PutEndElement(); return(mn.GetNodes()); }
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); }
public int c03() { ManagedNodeWriter mn = new ManagedNodeWriter(); mn.PutPattern("XE/"); mn.PutText("-->"); 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); }
//[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("�"); //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); }
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()); }
//[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("�"); 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); }