public void v2() { XmlSchemaSet sc = new XmlSchemaSet(); //remove after compile XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor); sc.Compile(); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); ICollection Col = sc.Schemas(); CError.Compare(Col.Count, 0, "ICollection.Count"); //remove before compile Schema1 = sc.Add(null, TestData._XsdAuthor); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); Col = sc.Schemas(); CError.Compare(Col.Count, 0, "ICollection.Count"); return; }
public void v1() { try { XmlSchemaSet sc = new XmlSchemaSet(); sc.RemoveRecursive(null); } catch (ArgumentNullException) { // GLOBALIZATION return; } Assert.True(false); }
public void v1(String testDir, String testFile, int expCount, int expCountGT, int expCountGE, int expCountGA) { Initialize(); string xsd = Path.Combine(path, testDir, testFile); XmlSchemaSet ss = new XmlSchemaSet(); XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback); ss.XmlResolver = new XmlUrlResolver(); XmlSchema Schema1 = ss.Add(Schema); ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add"); ValidateWithSchemaInfo(ss); ss.Compile(); ValidateSchemaSet(ss, expCount, true, expCountGT, expCountGE, expCountGA, "Validation after add/comp"); ValidateWithSchemaInfo(ss); XmlSchema Schema2 = null; foreach (XmlSchema schema in ss.Schemas()) Schema2 = ss.Reprocess(schema); ValidateSchemaSet(ss, expCount, false, 1, 0, 0, "Validation after repr"); ValidateWithSchemaInfo(ss); ss.Compile(); ValidateSchemaSet(ss, expCount, true, expCountGT, expCountGE, expCountGA, "Validation after repr/comp"); ValidateWithSchemaInfo(ss); Assert.Equal(ss.RemoveRecursive(Schema), true); ValidateSchemaSet(ss, 0, false, 1, 0, 0, "Validation after remRec"); ValidateWithSchemaInfo(ss); ss.Compile(); ValidateSchemaSet(ss, 0, true, 0, 0, 0, "Validation after remRec/comp"); ValidateWithSchemaInfo(ss); return; }
public void AddRollbackIsCompiled () { XmlSchemaSet ss = new XmlSchemaSet (); ss.Add (new XmlSchema ()); ss.Compile (); Assert.IsTrue (ss.IsCompiled, "#1"); XmlSchema sc = new XmlSchema (); // compiled one sc.Compile (null); ss.Add (sc); Assert.IsFalse (ss.IsCompiled, "#2"); ss.Add (new XmlSchema ()); // not-compiled one Assert.IsFalse (ss.IsCompiled, "#3"); XmlSchema s; s = new XmlSchema (); s.TargetNamespace = "urn:foo"; XmlSchemaElement el; el = new XmlSchemaElement (); el.Name = "root"; s.Items.Add (el); ss.Add (s); s = new XmlSchema (); s.TargetNamespace = "urn:foo"; el = new XmlSchemaElement (); el.Name = "foo"; s.Items.Add (el); ss.Add (s); ss.Compile (); Assert.IsTrue (ss.IsCompiled, "#4"); ss.RemoveRecursive (s); Assert.IsTrue (ss.IsCompiled, "#5"); }
public void v3() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor); XmlSchema Schema2 = sc.Add("test", TestData._XsdNoNs); sc.Compile(); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 1, "Count"); ICollection Col = sc.Schemas(); CError.Compare(Col.Count, 1, "ICollection.Count"); CError.Compare(sc.Contains("test"), true, "Contains"); return; }
public void v11(object param0) { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); sc.ValidationEventHandler += new ValidationEventHandler(ValidationCallback); bWarningCallback = false; bErrorCallback = false; try { //after compile XmlSchema Schema1 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); sc.Compile(); CError.Compare(sc.Count, 4, "Count"); sc.RemoveRecursive(Schema1); sc.Compile(); CError.Compare(sc.Count, 0, "Count"); CError.Compare(sc.GlobalElements.Count, 0, "Global Elements Count"); CError.Compare(sc.GlobalTypes.Count, 0, "Global Types Count");//should contain xs:anyType //before compile Schema1 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); CError.Compare(sc.Count, 4, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); CError.Compare(sc.GlobalElements.Count, 0, "Global Elements Count"); CError.Compare(sc.GlobalTypes.Count, 0, "Global Types Count"); //should contain xs:anyType } catch (Exception e) { _output.WriteLine(e.ToString()); Assert.True(false); } return; }
public void v10(object param0, object param1) { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); sc.ValidationEventHandler += new ValidationEventHandler(ValidationCallback); bWarningCallback = false; bErrorCallback = false; try { //after compile XmlSchema Schema1 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); XmlSchema Schema2 = sc.Add(null, Path.Combine(TestData._Root, param1.ToString())); sc.Compile(); CError.Compare(sc.Count, 5, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 5, "Count"); CError.Compare(bWarningCallback, true, "Warning Callback"); CError.Compare(bErrorCallback, false, "Error Callback"); //reinit bWarningCallback = false; bErrorCallback = false; sc.Remove(Schema2); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); CError.Compare(bWarningCallback, false, "Warning Callback"); CError.Compare(bErrorCallback, false, "Error Callback"); //before compile Schema1 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); Schema2 = sc.Add(null, Path.Combine(TestData._Root, param1.ToString())); CError.Compare(sc.Count, 5, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 5, "Count"); CError.Compare(bWarningCallback, true, "Warning Callback"); CError.Compare(bErrorCallback, false, "Error Callback"); } catch (Exception e) { _output.WriteLine(e.ToString()); Assert.True(false); } return; }
public void v9() { try { XmlSchemaSet sc = new XmlSchemaSet(); sc.Add(null, Path.Combine(TestData._Root, "import_v16_b.xsd")); //before compile XmlSchema parent = sc.Add(null, Path.Combine(TestData._Root, "import_v16_a.xsd")); sc.Compile(); sc.RemoveRecursive(parent); CError.Compare(sc.Count, 1, "Count"); CError.Compare(sc.Contains("ns-b"), true, "Contains"); //after compile parent = sc.Add(null, Path.Combine(TestData._Root, "import_v16_a.xsd")); sc.RemoveRecursive(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 v8(object param0) { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); try { //after compile XmlSchema Schema1 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); sc.Compile(); CError.Compare(sc.Count, 4, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); CError.Compare(sc.Contains("ns-d"), false, "Contains"); CError.Compare(sc.Contains("ns-c"), false, "Contains"); CError.Compare(sc.Contains("ns-b"), false, "Contains"); CError.Compare(sc.Contains("ns-a"), false, "Contains"); //before compile Schema1 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); CError.Compare(sc.Count, 4, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); CError.Compare(sc.Contains("ns-d"), false, "Contains"); CError.Compare(sc.Contains("ns-c"), false, "Contains"); CError.Compare(sc.Contains("ns-b"), false, "Contains"); CError.Compare(sc.Contains("ns-a"), false, "Contains"); } catch (Exception e) { _output.WriteLine(e.ToString()); Assert.True(false); } return; }
public void v6() { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); try { //after compile XmlSchema Schema1 = sc.Add("ns-b", Path.Combine(TestData._Root, "import_v4_b.xsd")); XmlSchema Schema2 = sc.Add(null, Path.Combine(TestData._Root, "import_v5_a.xsd")); // param as filename sc.Compile(); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 2, "Count"); CError.Compare(sc.Contains("ns-b"), false, "Contains"); CError.Compare(sc.Contains(String.Empty), true, "Contains"); CError.Compare(sc.Contains("ns-a"), true, "Contains"); sc.RemoveRecursive(Schema2); ICollection Col = sc.Schemas(); CError.Compare(Col.Count, 0, "ICollection.Count"); CError.Compare(sc.Contains("ns-b"), false, "Contains"); CError.Compare(sc.Contains(String.Empty), false, "Contains"); CError.Compare(sc.Contains("ns-a"), false, "Contains"); //before compile Schema1 = sc.Add("ns-b", Path.Combine(TestData._Root, "import_v4_b.xsd")); Schema2 = sc.Add(null, Path.Combine(TestData._Root, "import_v5_a.xsd")); // param as filename sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 2, "Count"); CError.Compare(sc.Contains("ns-b"), false, "Contains"); CError.Compare(sc.Contains(String.Empty), true, "Contains"); CError.Compare(sc.Contains("ns-a"), true, "Contains"); sc.RemoveRecursive(Schema2); Col = sc.Schemas(); CError.Compare(Col.Count, 0, "ICollection.Count"); CError.Compare(sc.Contains("ns-b"), false, "Contains"); CError.Compare(sc.Contains(String.Empty), false, "Contains"); CError.Compare(sc.Contains("ns-a"), false, "Contains"); } catch (Exception e) { _output.WriteLine(e.ToString()); Assert.True(false); } return; }
public void v5(object param0, object param1) { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); try { XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor); //remove after compile XmlSchema Schema2 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); // param as filename sc.Compile(); sc.RemoveRecursive(Schema2); CError.Compare(sc.Count, param1, "Count"); ICollection Col = sc.Schemas(); CError.Compare(Col.Count, param1, "ICollection.Count"); //remove before compile Schema2 = sc.Add(null, Path.Combine(TestData._Root, param0.ToString())); // param as filename sc.RemoveRecursive(Schema2); CError.Compare(sc.Count, param1, "Count"); Col = sc.Schemas(); CError.Compare(Col.Count, param1, "ICollection.Count"); } catch (Exception e) { _output.WriteLine(e.ToString()); Assert.True(false); } return; }
public void v5(object param0, object param1, object param2, object param3, object param4) { string uri1 = param0.ToString(); string ns1 = param1.ToString(); string type1 = param2.ToString(); string ns2 = param3.ToString(); string type2 = param4.ToString(); XmlSchemaSet ss = new XmlSchemaSet(); ss.XmlResolver = new XmlUrlResolver(); ss.Add(null, TestData._Root + "xsdauthor.xsd"); XmlSchema schema1 = ss.Add(null, TestData._Root + uri1); ss.Compile(); CError.Compare(ss.GlobalTypes.Count, 3, "Types Count"); //+1 for anyType CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type1, ns1)), true, "Contains1"); CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type2, ns2)), true, "Contains2"); ss.RemoveRecursive(schema1); // should not need to compile for RemoveRecursive to take effect CError.Compare(ss.GlobalTypes.Count, 1, "Types Count"); //+1 for anyType CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type1, ns1)), false, "Contains1"); CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type2, ns2)), false, "Contains2"); return; }
public void v2(String testDir, String testFile, int expCount) { Initialize(); string xsd = Path.Combine(path, testDir, testFile + ".xsd"); string xml = Path.Combine(path, testDir, testFile + ".xml"); XmlSchemaSet ss = new XmlSchemaSet(); ss.XmlResolver = new XmlUrlResolver(); XmlSchema schema = ss.Add(null, XmlReader.Create(xsd)); Assert.Equal(ss.Count, expCount); ss.Compile(); Assert.Equal(ss.Count, expCount); XmlSchemaElement element = new XmlSchemaElement(); schema.Items.Add(element); element.Name = "book"; element.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); foreach (XmlSchema sc in ss.Schemas()) ss.Reprocess(sc); Assert.Equal(ss.Count, expCount); ss.Compile(); Assert.Equal(ss.Count, expCount); ValidateWithXmlReader(ss, xml, xsd); Assert.Equal(ss.Count, expCount); ss.Compile(); Assert.Equal(ss.Count, expCount); ss.RemoveRecursive(schema); Assert.Equal(ss.Count, 0); ss.Compile(); Assert.Equal(ss.Count, 0); try { ss.Reprocess(schema); Assert.True(false); } catch (ArgumentException e) { _output.WriteLine(e.Message); Assert.Equal(ss.Count, 0); } return; }
public void v2(String testDir, String testFile, int expCount, int expCountGT, int expCountGE, int expCountGA, int expCountGER, int expCountGERC) { Initialize(); string xsd = Path.Combine(path, testDir, testFile + ".xsd"); string xml = Path.Combine(path, testDir, testFile + ".xml"); XmlSchemaSet ss = new XmlSchemaSet(); XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback); ss.XmlResolver = new XmlUrlResolver(); XmlSchema Schema1 = ss.Add(Schema); ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add"); ValidateWithXmlReader(ss, xml, xsd); ss.Compile(); ValidateSchemaSet(ss, expCount, true, expCountGT, expCountGE, expCountGA, "Validation after add/comp"); ValidateWithXmlReader(ss, xml, xsd); ss.Remove(Schema); ValidateSchemaSet(ss, expCount - 1, false, 1, expCountGER, 0, "Validation after rem"); ValidateWithXmlReader(ss, xml, xsd); ss.Compile(); ValidateSchemaSet(ss, expCount - 1, true, expCountGERC, expCountGER, 0, "Validation after add"); ValidateWithXmlReader(ss, xml, xsd); XmlSchema Schema2 = null; try { Schema2 = ss.Reprocess(Schema); Assert.True(false); } catch (ArgumentException e) { _output.WriteLine(e.Message); } ValidateSchemaSet(ss, expCount - 1, true, expCountGERC, expCountGER, 0, "Validation after repr"); ValidateWithXmlReader(ss, xml, xsd); Assert.Equal(ss.RemoveRecursive(Schema), false); ValidateSchemaSet(ss, expCount - 1, true, expCountGERC, expCountGER, 0, "Validation after remRec"); ValidateWithXmlReader(ss, xml, xsd); ss.Compile(); ValidateSchemaSet(ss, expCount - 1, true, expCountGERC, expCountGER, 0, "Validation after remRec/comp"); ValidateWithXmlReader(ss, xml, xsd); return; }
public void v1(String TestFile, int expCount) { Initialize(); string xsd = path + TestFile; XmlSchemaSet ss = new XmlSchemaSet(); XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback); ss.XmlResolver = new XmlUrlResolver(); XmlSchema schema = ss.Add(Schema); Assert.Equal(ss.Count, expCount); ss.Compile(); Assert.Equal(ss.Count, expCount); XmlSchemaElement element = new XmlSchemaElement(); schema.Items.Add(element); element.Name = "book"; element.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); foreach (XmlSchema sc in ss.Schemas()) ss.Reprocess(sc); Assert.Equal(ss.Count, expCount); ss.Compile(); Assert.Equal(ss.Count, expCount); ValidateWithSchemaInfo(ss); Assert.Equal(ss.Count, expCount); ss.Compile(); Assert.Equal(ss.Count, expCount); ss.RemoveRecursive(Schema); Assert.Equal(ss.Count, 0); ss.Compile(); Assert.Equal(ss.Count, 0); try { ss.Reprocess(Schema); Assert.True(false); } catch (ArgumentException e) { _output.WriteLine(e.Message); Assert.Equal(ss.Count, 0); } return; }
public void v7(object param0, object param1, object param2, object param3) { XmlSchemaSet sc = new XmlSchemaSet(); sc.XmlResolver = new XmlUrlResolver(); try { //after compile XmlSchema Schema1 = sc.Add(null, TestData._Root + param0.ToString()); sc.Compile(); CError.Compare(sc.Count, 3, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); CError.Compare(sc.Contains(param1.ToString()), false, "Contains"); CError.Compare(sc.Contains(param2.ToString()), false, "Contains"); CError.Compare(sc.Contains(param3.ToString()), false, "Contains"); //before compile Schema1 = sc.Add(null, TestData._Root + param0.ToString()); CError.Compare(sc.Count, 3, "Count"); sc.RemoveRecursive(Schema1); CError.Compare(sc.Count, 0, "Count"); CError.Compare(sc.Contains(param1.ToString()), false, "Contains"); CError.Compare(sc.Contains(param2.ToString()), false, "Contains"); CError.Compare(sc.Contains(param3.ToString()), false, "Contains"); } catch (Exception e) { _output.WriteLine(e.ToString()); Assert.True(false); } return; }