public void v105() { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); int elem_count = 0; XmlSchema schema = sc.Add(null, Path.Combine(TestData._Root, "include_v10_a.xsd")); CError.Compare(sc.Count, 1, "AddCount"); CError.Compare(sc.IsCompiled, false, "AddIsCompiled"); sc.Reprocess(schema); CError.Compare(sc.IsCompiled, false, "ReprocessIsCompiled"); CError.Compare(sc.Count, 1, "ReprocessCount"); sc.Compile(); CError.Compare(sc.IsCompiled, true, "IsCompiled"); CError.Compare(sc.Count, 1, "Count"); // Check that C's data is present in A's NS foreach (object obj in schema.Elements.Names) { if ((obj.ToString()).Equals("c-e2")) { elem_count++; } } CError.Compare(elem_count, 1, "c-e2"); elem_count = 0; // Check that B's data is present in A's NS foreach (object obj in schema.Elements.Names) { if ((obj.ToString()).Equals("b-e1")) { elem_count++; } } CError.Compare(elem_count, 1, "b-e1"); return; }
public int Variation_17() { ReloadSource(); // Add string object objAdded = DataReader.NameTable.Add(strVal); // Look for permutations of strings, should be null. for (int i = 0; i < strPerValCase.Length; i++) { char[] ach = strPerValCase[i].ToCharArray(); object objActual = DataReader.NameTable.Get(ach, 0, ach.Length); object objActual1 = DataReader.NameTable.Get(ach, 0, ach.Length); CError.Compare(objActual, null, CurVariation.Desc); CError.Compare(objActual, objActual1, CurVariation.Desc); } return(TEST_PASS); }
public int TestReadStartElement3() { ReloadSource(); DataReader.PositionOnElement(ST_TEST_ELEM_NS); DataReader.PositionOnElement("bar:check"); CError.WriteLine(DataReader.NamespaceURI); DataReader.ReadStartElement(); ReloadSource(); DataReader.PositionOnElement(ST_TEST_ELEM_NS); DataReader.PositionOnElement("bar:check"); CError.WriteLine(DataReader.NamespaceURI); DataReader.ReadStartElement("check", "1"); ReloadSource(); DataReader.PositionOnElement(ST_TEST_ELEM_NS); DataReader.PositionOnElement("bar:check"); DataReader.ReadStartElement("bar:check"); return(TEST_PASS); }
public int SkipAfterReadAttributeValueAndReadValueChunkDoesNotThrow() { XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; XmlReader reader = XmlReader.Create(FilePathUtil.getStream(this.StandardPath + @"\XML10\ms_xml\vs084.xml"), settings); reader.ReadToFollowing("a"); reader.MoveToNextAttribute(); reader.ReadAttributeValue(); reader.ReadValueChunk(new char[3], 0, 3); //<< removing this line works fine. reader.Skip(); CError.Compare(reader.NodeType, XmlNodeType.Whitespace, "NT"); reader.Read(); CError.Compare(reader.NodeType, XmlNodeType.Element, "NT1"); CError.Compare(reader.Name, "a", "Name"); return(TEST_PASS); }
public void v10() { try { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); sc.Add(null, Path.Combine(TestData._Root, "import_v16_b.xsd")); XmlSchema parent = sc.Add(null, Path.Combine(TestData._Root, "import_v16_a.xsd")); sc.Compile(); sc.Remove(parent); CError.Compare(sc.Count, 1, "Count"); CError.Compare(sc.Contains("ns-b"), true, "Contains"); return; } catch (XmlSchemaException e) { _output.WriteLine("Exception : " + e.Message); } Assert.True(false); }
public void indent_26(XmlWriterUtils utils, ConformanceLevel conformanceLevel) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; wSettings.ConformanceLevel = conformanceLevel; using (XmlWriter w = utils.CreateWriter(wSettings)) { w.WriteStartElement("root"); w.WriteStartElement("child"); w.WriteStartElement("a"); w.WriteEndElement(); w.WriteString("text"); w.WriteStartElement("a"); } CError.Compare(utils.CompareString("<root>" + wSettings.NewLineChars + " <child>" + wSettings.NewLineChars + " <a />text<a /></child>" + wSettings.NewLineChars + "</root>"), ""); return; }
public void state_1(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { try { w.WriteStartDocument(); w.WriteEntityRef("ent"); } catch (InvalidOperationException e) { CError.WriteLineIgnore("Exception: " + e.ToString()); CError.Compare(w.WriteState, WriteState.Error, "WriteState should be Error"); return; } } CError.WriteLine("Did not throw exception"); Assert.True(false); }
protected void CompareSettings() { XmlWriterSettings actual = _factoryWriter.Settings; CError.Compare(actual.CheckCharacters, _settings.CheckCharacters, "CheckCharacters"); //This actually checks Conformance Level DCR to some extent. if (_settings.ConformanceLevel != ConformanceLevel.Auto) { CError.Compare(actual.ConformanceLevel, _settings.ConformanceLevel, "ConformanceLevel"); } CError.Compare(actual.Encoding, _settings.Encoding, "Encoding"); CError.Compare(actual.Indent, _settings.Indent, "Indent"); CError.Compare(actual.IndentChars, _settings.IndentChars, "IndentChars"); CError.Compare(actual.NewLineChars, _settings.NewLineChars, "NewLineChars"); CError.Compare(actual.NewLineOnAttributes, _settings.NewLineOnAttributes, "NewLineOnAttributes"); CError.Compare(actual.NewLineHandling, _settings.NewLineHandling, "NormalizeNewLines"); CError.Compare(actual.OmitXmlDeclaration, _settings.OmitXmlDeclaration, "OmitXmlDeclaration"); }
public int TestReadBinHex_27() { byte[] buffer = new byte[1]; string strxml = "<abc>1=2</abc>"; ReloadSource(new StringReader(strxml)); DataReader.PositionOnElement("abc"); if (CheckCanReadBinaryContent()) { return(TEST_PASS); } try { DataReader.ReadElementContentAsBinHex(buffer, 0, 1); CError.Compare(false, "ReadBinHex with = in the middle succeeded"); } catch (XmlException) { return(TEST_PASS); } finally { DataReader.Close(); } return(TEST_FAIL); }
public void writeAttributes_3(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { XmlReader xr = null; try { w.WriteStartElement("Root"); w.WriteAttributes(xr, false); } catch (ArgumentNullException e) { CError.WriteLineIgnore("Exception: " + e.ToString()); CError.Compare(w.WriteState, WriteState.Element, "WriteState should be Element"); return; } } CError.WriteLine("Did not throw exception"); Assert.True(false); }
public void attribute_9(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { try { w.WriteStartElement("Root"); w.WriteStartAttribute("ns1", "attr1", "http://my.com"); w.WriteStartAttribute("ns1", "attr1", "http://my.com"); } catch (XmlException e) { CError.WriteLineIgnore("Exception: " + e.ToString()); CError.Compare(w.WriteState, WriteState.Error, "WriteState should be Error"); return; } } CError.WriteLine("Did not throw exception"); Assert.True(false); }
public int v17() { ReloadSource(new StringReader("<root><child1 xmlns='foo'/>blah<child1 xmlns='bar'>blah</child1></root>")); DataReader.Read(); if (IsBinaryReader()) { DataReader.Read(); } DataReader.ReadToFollowing("child1", "bar"); CError.Compare(DataReader.IsEmptyElement, false, "Not on the correct node"); while (DataReader.Read()) { ; } DataReader.Close(); return(TEST_PASS); }
public int GetReadState() { ReloadSource(); ReadState iState = ReadState.Initial; // EndOfFile State if ((IntegrityVer == EINTEGRITY.AFTER_READ_FALSE)) { iState = ReadState.EndOfFile; } // Closed State if ((IntegrityVer == EINTEGRITY.AFTER_CLOSE) || (IntegrityVer == EINTEGRITY.CLOSE_IN_THE_MIDDLE)) { iState = ReadState.Closed; } CError.Compare(DataReader.ReadState, iState, CurVariation.Desc); CError.Compare(DataReader.ReadState, iState, CurVariation.Desc); return(TEST_PASS); }
//[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root>񘍁<Elem>󏹄</Elem>𘀢</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<root>va</root>lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a='&' b='&#65;' c='&#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a='b"c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a=' 	
' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root foo='& < > " ' A'/>" })] public int v30() { string xml = CurVariation.Params[0] as string; int val = xml.Length; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersInDocument = val; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) { ; } CError.Compare(reader.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, val, "Error"); } return(TEST_PASS); }
public void EOF_Handling_22(XmlWriterUtils utils, NewLineHandling nlHandling) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.NewLineHandling = nlHandling; wSettings.Indent = true; wSettings.NewLineChars = "\uDE40\uDA72"; wSettings.IndentChars = "\uDE40\uDA72"; XmlWriter w = CreateMemWriter(utils, wSettings); try { w.WriteStartElement("root"); w.WriteStartElement("foo"); w.Dispose(); } catch (ArgumentException e) { CError.WriteLine(e.Message); return; } Assert.True(false); }
public override int Init(object o) { int i = base.Init(0); if (this.Param != null) { switch (this.Param.ToString().ToUpperInvariant()) { case "COREREADER": readerType = ReaderType.CoreReader; break; default: CError.Compare(false, "Unknown reader type: " + readerType); break; } } return(i); }
//[Variation(Desc = "write start element and then close when the WriteEndDocumentOnClose = false", Pri = 1, Params = new object[] { false, "<root>" })] //[Variation(Desc = "write start element and then close when the WriteEndDocumentOnClose = true", Pri = 1, Params = new object[] { true, "<root />" })] public int TestWriteEndDocumentOnCoseForOneElement() { bool writeEndDocument = (bool)CurVariation.Params[0]; string expected = (string)CurVariation.Params[1]; StringWriter output = new StringWriter(); XmlWriterSettings ws = new XmlWriterSettings(); ws.OmitXmlDeclaration = true; ws.WriteEndDocumentOnClose = writeEndDocument; XmlWriter writer = XmlWriter.Create(output, ws); writer.WriteStartElement("root"); writer.Dispose(); string act = output.ToString(); CError.Compare(act, expected, "FAILED: when one start element and WriteEndDocumentOnClose = " + ws.WriteEndDocumentOnClose + ", expected: " + expected + ", received: " + act); return(TEST_PASS); }
public XmlReader CreateReader(TextReader sr) { XmlReader xr = null; XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.DtdProcessing = DtdProcessing.Parse; readerSettings.CloseInput = true; switch (readerType) { case ReaderType.CoreReader: xr = ReaderHelper.Create(sr, readerSettings, (string)null); break; default: CError.Compare(false, "Unknown reader type: " + readerType); break; } return(xr); }
public XmlReader CreateReaderIgnoreWS(TextReader sr) { XmlReader xr = null; XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.CloseInput = true; readerSettings.IgnoreWhitespace = true; switch (readerType) { case ReaderType.CoreReader: xr = ReaderHelper.Create(sr, readerSettings, (String)null /*baseUri*/); break; default: CError.Compare(false, "Unknown reader type: " + readerType); break; } return(xr); }
public void v11(object param0) { Initialize(); try { XmlSchema schema = XmlSchema.Read(CreateReader(TestData._Root + param0.ToString(), false), ValidationCallback); #pragma warning disable 0618 schema.Compile(ValidationCallback); #pragma warning restore 0618 } catch (XmlException) { Assert.True(false); } CError.Compare(warningCount, 0, "Warning Count mismatch"); CError.Compare(errorCount, 0, "Warning Count mismatch"); return; }
public void v4() { Initialize(); XmlSchemaSet xss = new XmlSchemaSet(); xss.XmlResolver = new XmlUrlResolver(); xss.ValidationEventHandler += ValidationCallback; XmlReader r = CreateReader(TestData._Root + "bug356711.xsd"); try { xss.Add(null, r); } catch (XmlException) { Assert.True(false); //exepect a validation warning for unresolvable schema location } CError.Compare(warningCount, 1, "Warning Count mismatch"); return; }
public void writeNode_XmlReader1(XmlWriterUtils utils) { XmlReader xr = null; using (XmlWriter w = utils.CreateWriter()) { try { w.WriteStartElement("Root"); w.WriteNode(xr, false); } catch (ArgumentNullException) { CError.Compare(w.WriteState, WriteState.Element, "WriteState should be Element"); return; } } CError.WriteLine("Did not throw exception"); Assert.True(false); }
//[Variation(Desc = "16.Test fo proper indentation and newline handling when Indent = true, with custom NewLineChars and IndentChars; Entitize, '\uDE40\uDA72', '\uDE40\uDA72'", Params = new object[] { NewLineHandling.Entitize })] //[Variation(Desc = "17.Test fo proper indentation and newline handling when Indent = true, with custom NewLineChars and IndentChars; Replace, '\uDE40\uDA72', '\uDE40\uDA72'", Params = new object[] { NewLineHandling.Replace })] //[Variation(Desc = "18.Test fo proper indentation and newline handling when Indent = true, with custom NewLineChars and IndentChars; None, '\uDE40\uDA72', '\uDE40\uDA72'", Params = new object[] { NewLineHandling.None })] public int EOF_Handling_22() { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.NewLineHandling = (NewLineHandling)CurVariation.Params[0]; wSettings.Indent = true; wSettings.NewLineChars = "\uDE40\uDA72"; wSettings.IndentChars = "\uDE40\uDA72"; XmlWriter w = CreateMemWriter(wSettings); try { w.WriteStartElement("root"); w.WriteStartElement("foo"); w.Dispose(); } catch (ArgumentException e) { CError.WriteLine(e.Message); return(TEST_PASS); } return(TEST_FAIL); }
public int v8() { ReloadSource(new StringReader(_xmlStr)); DataReader.PositionOnElement("root"); CError.Compare(DataReader.ReadToFollowing("e:elem"), true, "Cant find elem"); CError.Compare(DataReader.ReadToFollowing("e:child1"), true, "Cant find child1"); CError.Compare(DataReader.ReadToFollowing("e:child2"), true, "Cant find child2"); CError.Compare(DataReader.ReadToFollowing("e:child3"), true, "Cant find child3"); CError.Compare(DataReader.ReadToFollowing("e:child4"), true, "Cant fine child4"); CError.Compare(DataReader.NodeType, XmlNodeType.Element, "Not on Element"); while (DataReader.Read()) { ; } DataReader.Close(); return(TEST_PASS); }
public void v2(object param0, object param1, object param2, object param3, object param4, object param5) { string ns1 = param0.ToString(); string ns2 = param3.ToString(); string a1 = param1.ToString(); string a2 = param2.ToString(); string a3 = param4.ToString(); string a4 = param5.ToString(); XmlSchema s1 = GetSchema(ns1, a1, a2); XmlSchema s2 = GetSchema(ns2, a3, a4); XmlSchemaSet ss = new XmlSchemaSet(); ss.Add(s1); ss.Compile(); ss.Add(s2); CError.Compare(ss.GlobalAttributes.Count, 2, "Elements Countafter add"); //+1 for anyType ss.Compile(); //Verify CError.Compare(ss.GlobalAttributes.Count, 4, "Elements Count after add/compile"); CError.Compare(ss.GlobalAttributes.Contains(new XmlQualifiedName(a1, ns1)), true, "Contains1"); CError.Compare(ss.GlobalAttributes.Contains(new XmlQualifiedName(a2, ns1)), true, "Contains2"); CError.Compare(ss.GlobalAttributes.Contains(new XmlQualifiedName(a3, ns2)), true, "Contains3"); CError.Compare(ss.GlobalAttributes.Contains(new XmlQualifiedName(a4, ns2)), true, "Contains4"); //Now reprocess one schema and check ss.Reprocess(s1); ss.Compile(); CError.Compare(ss.GlobalAttributes.Count, 4, "Elements Count after reprocess"); //Now Remove one schema and check ss.Remove(s1); CError.Compare(ss.GlobalAttributes.Count, 2, "Elements Count after remove no compile"); ss.Compile(); CError.Compare(ss.GlobalAttributes.Count, 2, "Elements Count adter remove and compile"); return; }
//[Variation("ReadBinHex runs into an Overflow", Params = new object[] { "1000000" })] //[Variation("ReadBinHex runs into an Overflow", Params = new object[] { "10000000" })] public int TestReadBinHex_105376() { int totalfilesize = Convert.ToInt32(CurVariation.Params[0].ToString()); CError.WriteLine(" totalfilesize = " + totalfilesize); string ascii = new string('c', totalfilesize); byte[] bits = Encoding.Unicode.GetBytes(ascii); CError.WriteLineIgnore("Count = " + bits.Length); string base64str = Convert.ToBase64String(bits); string fileName = "bug105376c_" + CurVariation.Params[0].ToString() + ".xml"; MemoryStream mems = new MemoryStream(); StreamWriter sw = new StreamWriter(mems); sw.Write("<root><base64>"); sw.Write(base64str); sw.Write("</base64></root>"); sw.Flush();//sw.Close(); FilePathUtil.addStream(fileName, mems); ReloadSource(fileName); int SIZE = (totalfilesize - 30); int SIZE64 = SIZE * 3 / 4; DataReader.PositionOnElement("base64"); if (CheckCanReadBinaryContent()) { return(TEST_PASS); } byte[] base64 = new byte[SIZE64]; try { DataReader.ReadElementContentAsBinHex(base64, 0, 4096); return(TEST_FAIL); } catch (XmlException) { DataReader.Close(); return(TEST_PASS); } finally { DataReader.Close(); } }
public void v9() { bWarningCallback = false; bErrorCallback = false; XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); sc.ValidationEventHandler += new ValidationEventHandler(ValidationCallback); XmlSchema Schema1 = sc.Add(null, Path.Combine(TestData._Root, "reprocess_v9_a.xsd")); CError.Compare(sc.Count, 2, "Count after add"); CError.Compare(sc.Contains(Schema1), true, "Contains after add"); sc.Compile(); CError.Compare(sc.Count, 2, "Count"); CError.Compare(sc.Contains(Schema1), true, "Contains"); //edit XmlSchemaImport imp = new XmlSchemaImport(); imp.Namespace = "ns-c"; imp.SchemaLocation = "reprocess_v9_c.xsd"; Schema1.Includes.Add(imp); sc.Reprocess(Schema1); CError.Compare(bWarningCallback, false, "Warning"); CError.Compare(bErrorCallback, false, "Error"); CError.Compare(sc.Count, 3, "Count"); CError.Compare(sc.Contains(Schema1), true, "Contains"); CError.Compare(sc.IsCompiled, false, "IsCompiled"); sc.Compile(); CError.Compare(sc.IsCompiled, true, "IsCompiled"); CError.Compare(Schema1.IsCompiled, true, "IsCompiled on SOM"); return; }
public int TestLinePos99() { string strxml = "<portfolio>\n <stock exchange=nasdaq/>\n</portfolio>"; ReloadSourceStr(strxml); try { while (DataReader.Read()) { ; } } catch (XmlException e) { CError.Compare(e.LineNumber, 2, "ln"); CError.Compare(e.LinePosition, 18, "lp"); return(TEST_PASS); } return(TEST_FAIL); }
public int TestTextReadOuterXml29() { String strp = "a "; strp += strp; strp += strp; strp += strp; strp += strp; strp += strp; strp += strp; strp += strp; string strxml = "<Name a=\"b\">" + strp + " </Name>"; ReloadSourceStr(strxml); DataReader.Read(); CError.Compare(DataReader.ReadOuterXml(), strxml, "rox"); return(TEST_PASS); }
public void v3() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor); CError.Compare(sc.Count, 1, "AddCount"); CError.Compare(sc.Contains(Schema1), true, "AddContains"); CError.Compare(sc.IsCompiled, false, "AddIsCompiled"); sc.Compile(); CError.Compare(sc.Count, 1, "Compile"); CError.Compare(sc.Contains(Schema1), true, "Compile Contains"); CError.Compare(sc.IsCompiled, true, "Compile IsCompiled"); sc.Reprocess(Schema1); CError.Compare(sc.Count, 1, "IsCompiled on set"); CError.Compare(sc.IsCompiled, false, "Reprocess IsCompiled"); CError.Compare(sc.Contains(Schema1), true, "Reprocess Contains"); return; }