//[Variation(Desc = "v3 - Contains with existing schema, Remove it, Contains again")]
        public void v3()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            XmlSchema Schema = sc.Add("xsdauthor", TestData._XsdAuthor);
            Assert.Equal(sc.Contains("xsdauthor"), true);

            sc.Remove(Schema);

            Assert.Equal(sc.Contains("xsdauthor"), false);

            return;
        }
        public void v3()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.Add("xsdauthor1", TestData._XsdNoNs);
            XmlSchema Schema1 = sc.Add("xsdauthor", TestData._XsdAuthor);
            sc.Compile();
            sc.Remove(Schema1);

            CError.Compare(sc.IsCompiled, false, "IsCompiled after compiled and remove");

            return;
        }
Esempio n. 3
0
 public void v1()
 {
     try
     {
         XmlSchemaSet sc = new XmlSchemaSet();
         sc.Remove(null);
     }
     catch (ArgumentNullException)
     {
         // GLOBALIZATION
         return;
     }
     Assert.True(false);
 }
Esempio n. 4
0
        public void v2()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();
            XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
            sc.Compile();
            sc.Remove(Schema1);

            CError.Compare(sc.Count, 0, "Count");
            ICollection Col = sc.Schemas();
            CError.Compare(Col.Count, 0, "ICollection.Count");

            return;
        }
Esempio n. 5
0
        public void v3()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();
            XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
            XmlSchema Schema2 = sc.Add("test", TestData._XsdNoNs);
            sc.Compile();
            sc.Remove(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;
        }
        //[Variation(Desc = "v3 - Contains with existing schema, Remove it, Contains again", Priority = 0)]
        public void v3()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
#pragma warning disable 0618
            XmlSchemaCollection scl = new XmlSchemaCollection();
#pragma warning restore 0618

            XmlSchema Schema = scl.Add(null, TestData._XsdAuthor);
            sc.Add(Schema);

            Assert.Equal(sc.Contains(Schema), true);

            sc.Remove(Schema);

            Assert.Equal(sc.Contains(Schema), false);

            return;
        }
		/// <summary>
		/// Removes the duplicate schemas in a given XmlSchemaSet instance.
		/// </summary>
		private static void RemoveDuplicates(ref XmlSchemaSet set)
		{
			ArrayList schemalist = new ArrayList(set.Schemas());
			ArrayList duplicatedschemalist = new ArrayList();

			for (int schemaindex = 0; schemaindex < schemalist.Count; schemaindex++)
			{
				if (((XmlSchema)schemalist[schemaindex]).SourceUri == string.Empty)
				{
					duplicatedschemalist.Add(schemalist[schemaindex]);
				}
				else
				{
					for (int lowerschemaindex = schemaindex + 1; lowerschemaindex < schemalist.Count; lowerschemaindex++)
					{
						if (((XmlSchema)schemalist[lowerschemaindex]).SourceUri == ((XmlSchema)schemalist[schemaindex]).SourceUri)
						{
							duplicatedschemalist.Add(schemalist[lowerschemaindex]);
						}
					}
				}
			}
			foreach (XmlSchema schema in duplicatedschemalist)
			{
				set.Remove(schema);
			}
		}
Esempio n. 8
0
        public void v28()
        {
            string xmlns = @"http://www.w3.org/XML/1998/namespace";
            XmlSchema schema = null;

            XmlSchemaSet ss = new XmlSchemaSet();
            ss.XmlResolver = new XmlUrlResolver();
            ss.Add(null, Path.Combine(TestData._Root, "bug338038_v3.xsd"));
            ss.Compile();

            foreach (XmlSchema s in ss.Schemas(xmlns))
            {
                schema = s;
            }

            ss.Add(null, Path.Combine(TestData._Root, "bug338038_v4a.xsd"));
            ss.Compile();
            ss.Add(null, Path.Combine(TestData._Root, "bug338038_v5b.xsd"));
            ss.Compile();

            ss.Remove(schema);
            ss.Compile();

            foreach (XmlSchemaAttribute a in ss.GlobalAttributes.Values)
            {
                if (a.QualifiedName.Name == "blah")
                {
                    CError.Compare(a.AttributeSchemaType.QualifiedName.Name, "int", "Incorrect type for xml:lang");
                }
            }
            CError.Compare(ss.Count, 5, "Count of SchemaSet not matched!");
            return;
        }
        public void v3(object param0, object param1, object param2, object param3, object param4, object param5, object param6)
        {
            string ns1 = param0.ToString();
            string ns2 = param3.ToString();
            string a1 = param1.ToString();
            string a2 = param2.ToString();
            string a3 = param4.ToString();
            string a4 = param5.ToString();
            bool doCompile = (bool)param6;

            XmlSchema s1 = GetSchema(ns1, a1, a2);
            XmlSchema s2 = GetSchema(ns2, a3, a4);

            XmlSchemaSet ss1 = new XmlSchemaSet();
            XmlSchemaSet ss2 = new XmlSchemaSet();
            ss1.Add(s1);
            ss1.Compile();
            ss2.Add(s2);

            if (doCompile)
                ss2.Compile();

            // add one schemaset to another
            ss1.Add(ss2);

            if (!doCompile)
                ss1.Compile();
            //Verify
            CError.Compare(ss1.GlobalAttributes.Count, 4, "Types Count after add");
            CError.Compare(ss1.GlobalAttributes.Contains(new XmlQualifiedName(a1, ns1)), true, "Contains1");
            CError.Compare(ss1.GlobalAttributes.Contains(new XmlQualifiedName(a2, ns1)), true, "Contains2");
            CError.Compare(ss1.GlobalAttributes.Contains(new XmlQualifiedName(a3, ns2)), true, "Contains3");
            CError.Compare(ss1.GlobalAttributes.Contains(new XmlQualifiedName(a4, ns2)), true, "Contains4");

            //Now reprocess one schema and check
            ss1.Reprocess(s1);
            ss1.Compile();
            CError.Compare(ss1.GlobalAttributes.Count, 4, "Types Count after reprocess");

            //Now Remove one schema and check
            ss1.Remove(s1);
            CError.Compare(ss1.GlobalAttributes.Count, 2, "Types Count after repr/remove"); // count should still be 4
            ss1.Compile();
            CError.Compare(ss1.GlobalAttributes.Count, 2, "Types Count after repr/remove/comp"); // count should NOW still be 2

            return;
        }
        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;
        }
Esempio n. 11
0
        public void XmlSchemaSetCompileAfterRemovingLastSchemaInTheSetIsNotClearingCachedCompiledInformationUsedForValidation_2()
        {
            string schemaXml = @"<Schema:schema xmlns:Schema='http://www.w3.org/2001/XMLSchema' targetNamespace='uri1'>
    <Schema:element name='doc' type='Schema:string'/>
</Schema:schema>";

            string instanceXml = @"<doc xmlns='uri1'>some</doc>";
            XmlSchemaSet ss = new XmlSchemaSet(new NameTable());
            XmlSchema schema = XmlSchema.Read(new StringReader(schemaXml), null);

            ss.Add(schema);
            Assert.Equal(ss.Count, 1);
            ss.Compile();
            Assert.Equal(ss.Count, 1);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.Schemas = ss;
            settings.ValidationType = ValidationType.Schema;

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(instanceXml), settings))
            {
                while (xmlReader.Read()) ;
            }

            XmlSchema removedSchema = ss.Remove(schema);
            Assert.Equal(ss.Count, 0);
            ss.Compile();
            Assert.Equal(ss.Count, 0);

            settings = new XmlReaderSettings();
            settings.Schemas = ss;
            settings.ValidationType = ValidationType.Schema;

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(instanceXml), settings))
            {
                while (xmlReader.Read()) ;
            }
            return;
        }
Esempio n. 12
0
        public void v4()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            XmlSchema Schema1 = sc.Add("xsdauthor1", TestData._XsdNoNs);
            XmlSchema Schema2 = sc.Add("xsdauthor", TestData._XsdAuthor);
            ICollection Col = sc.Schemas();
            sc.Remove(Schema1);

            CError.Compare(Col.Count, 1, "Count");
            foreach (XmlSchema Schema in Col)
            {
                CError.Compare(Schema, Schema2, "Schema");
            }

            return;
        }
Esempio n. 13
0
        public void v6()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            XmlSchema Schema2 = sc.Add(null, TestData._XsdAuthor);

            sc.Remove(Schema2);
            ICollection Col = sc.Schemas("xsdauthor");

            CError.Compare(Col.Count, 0, "Count");

            foreach (XmlSchema Schema in Col)
            {
                XmlSchema a = Schema;
                _output.WriteLine("should never enter this loop");
                Assert.True(false);
            }
            return;
        }
Esempio n. 14
0
 public void v20()
 {
     XmlSchemaSet sc = new XmlSchemaSet();
     sc.XmlResolver = new XmlUrlResolver();
     XmlSchema Schema = sc.Add(null, TestData._XsdAuthor); // param as filename
     sc.Compile();
     CError.Compare(sc.Count, 1, "Count before remove");
     sc.Remove(Schema);
     sc.Compile();
     CError.Compare(sc.Count, 0, "Count after remove");
     CError.Compare(sc.GlobalElements.Count, 0, "GlobalElems Count");
     return;
 }
Esempio n. 15
0
        public void v2(object param0, object param1, object param2, object param3, object param4, object param5)
        {
            string ns1 = param0.ToString();
            string ns2 = param3.ToString();

            string type1 = param1.ToString();
            string type2 = param2.ToString();
            string type3 = param4.ToString();
            string type4 = param5.ToString();

            XmlSchema s1 = GetSchema(ns1, type1, type2);
            XmlSchema s2 = GetSchema(ns2, type3, type4);

            XmlSchemaSet ss = new XmlSchemaSet();
            ss.Add(s1);
            CError.Compare(ss.GlobalTypes.Count, 0, "Types Count after add");
            ss.Compile();
            ss.Add(s2);
            CError.Compare(ss.GlobalTypes.Count, 3, "Types Count after add/compile"); //+1 for anyType
            ss.Compile();

            //Verify
            CError.Compare(ss.GlobalTypes.Count, 5, "Types Count after add/compile/add/compile"); //+1 for anyType
            CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type1, ns1)), true, "Contains1");
            CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type2, ns1)), true, "Contains2");
            CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type3, ns2)), true, "Contains3");
            CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type4, ns2)), true, "Contains4");

            //Now reprocess one schema and check
            ss.Reprocess(s1);
            CError.Compare(ss.GlobalTypes.Count, 3, "Types Count after repr"); //+1 for anyType
            ss.Compile();
            CError.Compare(ss.GlobalTypes.Count, 5, "Types Count after repr/comp"); //+1 for anyType

            //Now Remove one schema and check
            ss.Remove(s1);
            CError.Compare(ss.GlobalTypes.Count, 3, "Types Count after remove");
            ss.Compile();
            CError.Compare(ss.GlobalTypes.Count, 3, "Types Count after remove/comp");

            return;
        }
Esempio n. 16
0
        public void v7()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();

            try
            {
                XmlSchema Schema1 = sc.Add("ns-b", TestData._Root + "import_v4_b.xsd");
                XmlSchema Schema2 = sc.Add(null, TestData._Root + "import_v5_a.xsd"); // param as filename
                sc.Compile();
                ICollection col = sc.Schemas(String.Empty);
                foreach (XmlSchema schema in col)
                {
                    sc.Remove(schema); //should remove just one
                }

                CError.Compare(sc.Count, 2, "Count");
                ICollection Col = sc.Schemas();
                CError.Compare(Col.Count, 2, "ICollection.Count");
                CError.Compare(sc.Contains("ns-b"), true, "Contains");
                CError.Compare(sc.Contains(String.Empty), false, "Contains");
                CError.Compare(sc.Contains("ns-a"), true, "Contains");
            }
            catch (Exception)
            {
                Assert.True(false);
            }
            return;
        }
Esempio n. 17
0
        public void v4(object param0)
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();

            try
            {
                XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
                XmlSchema Schema2 = sc.Add(null, TestData._Root + param0.ToString()); // param as filename

                sc.Compile();
                sc.Remove(Schema2);
                CError.Compare(sc.Count, 1, "Count");
                ICollection Col = sc.Schemas();
                CError.Compare(Col.Count, 1, "ICollection.Count");
            }
            catch (Exception)
            {
                Assert.True(false);
            }

            return;
        }
Esempio n. 18
0
        public void v9(object param0)
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();

            try
            {
                XmlSchema Schema1 = sc.Add(null, TestData._Root + param0.ToString());
                sc.Compile();
                CError.Compare(sc.Count, 4, "Count");

                ICollection col = sc.Schemas("ns-d");
                foreach (XmlSchema schema in col)
                {
                    sc.Remove(schema); //should remove just one
                }

                CError.Compare(sc.Count, 3, "Count");
                CError.Compare(sc.Contains("ns-d"), false, "Contains");

                col = sc.Schemas("ns-c");
                foreach (XmlSchema schema in col)
                {
                    sc.Remove(schema); //should remove just one
                }

                CError.Compare(sc.Count, 2, "Count");
                CError.Compare(sc.Contains("ns-c"), false, "Contains");

                col = sc.Schemas("ns-b");
                foreach (XmlSchema schema in col)
                {
                    sc.Remove(schema); //should remove just one
                }

                CError.Compare(sc.Count, 1, "Count");
                CError.Compare(sc.Contains("ns-b"), false, "Contains");
                CError.Compare(sc.Contains("ns-a"), true, "Contains");
            }
            catch (Exception e)
            {
                _output.WriteLine(e.ToString());
                Assert.True(false);
            }
            return;
        }
Esempio n. 19
0
 public void v10()
 {
     try
     {
         XmlSchemaSet sc = new XmlSchemaSet();
         sc.XmlResolver = new XmlUrlResolver();
         sc.Add(null, TestData._Root + "import_v16_b.xsd");
         XmlSchema parent = sc.Add(null, 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);
 }
Esempio n. 20
0
        public void v3(object param0, object param1, object param2, object param3, object param4, object param5, object param6)
        {
            string ns1 = param0.ToString();
            string ns2 = param3.ToString();
            string type1 = param1.ToString();
            string type2 = param2.ToString();
            string type3 = param4.ToString();
            string type4 = param5.ToString();
            bool doCompile = (bool)param6;

            XmlSchema s1 = GetSchema(ns1, type1, type2);
            XmlSchema s2 = GetSchema(ns2, type3, type4);

            XmlSchemaSet ss1 = new XmlSchemaSet();
            XmlSchemaSet ss2 = new XmlSchemaSet();
            ss1.Add(s1);

            ss1.Compile();
            ss2.Add(s2);

            if (doCompile)
                ss2.Compile();

            // add one schemaset to another
            ss1.Add(ss2);

            if (!doCompile)
                ss1.Compile();
            //Verify
            CError.Compare(ss1.GlobalTypes.Count, 5, "Types Count after add/comp"); //+1 for anyType
            CError.Compare(ss1.GlobalTypes.Contains(new XmlQualifiedName(type1, ns1)), true, "Contains1");
            CError.Compare(ss1.GlobalTypes.Contains(new XmlQualifiedName(type2, ns1)), true, "Contains2");
            CError.Compare(ss1.GlobalTypes.Contains(new XmlQualifiedName(type3, ns2)), true, "Contains3");
            CError.Compare(ss1.GlobalTypes.Contains(new XmlQualifiedName(type4, ns2)), true, "Contains4");

            //Now reprocess one schema and check
            ss1.Reprocess(s1);
            CError.Compare(ss1.GlobalTypes.Count, 3, "Types Count repr"); //+1 for anyType
            ss1.Compile();
            CError.Compare(ss1.GlobalTypes.Count, 5, "Types Count repr/comp"); //+1 for anyType

            //Now Remove one schema and check
            ss1.Remove(s1);
            CError.Compare(ss1.GlobalTypes.Count, 3, "Types Count after remove");
            ss1.Compile();
            CError.Compare(ss1.GlobalTypes.Count, 3, "Types Count after rem/comp");

            return;
        }
Esempio n. 21
0
        public void XmlSchemaSetCompileAfterRemovingLastSchemaInTheSetIsNotClearingCachedCompiledInformationUsedForValidation_1()
        {
            string schemaXml = @"
                <Schema:schema xmlns:Schema='http://www.w3.org/2001/XMLSchema'
                           targetNamespace='urn:test'
                           elementFormDefault='qualified'>
                    <Schema:element name='MyElement' type='Schema:int' />
                </Schema:schema>";

            string instanceXml = @"<MyElement xmlns='urn:test'>x100</MyElement>";
            XmlSchemaSet ss = new XmlSchemaSet(new NameTable());
            XmlSchema schema = XmlSchema.Read(new StringReader(schemaXml), null);

            ss.Add(schema);
            Assert.Equal(ss.Count, 1);
            ss.Compile();
            Assert.Equal(ss.Count, 1);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.Schemas = ss;
            settings.ValidationType = ValidationType.Schema;

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(instanceXml), settings))
            {
                try
                {
                    while (xmlReader.Read()) ;
                    Assert.True(false); ;
                }
                catch (XmlSchemaValidationException e)
                {
                    _output.WriteLine("before remove " + e.Message);
                }
            }

            XmlSchema removedSchema = ss.Remove(schema);
            Assert.Equal(ss.Count, 0);
            ss.Compile();
            Assert.Equal(ss.Count, 0);

            settings = new XmlReaderSettings();
            settings.Schemas = ss;
            settings.ValidationType = ValidationType.Schema;

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(instanceXml), settings))
            {
                while (xmlReader.Read()) ;
            }
            return;
        }
Esempio n. 22
0
        public void v4(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();
            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");

            //get the SOM for the imported schema
            foreach (XmlSchema s in ss.Schemas(ns2))
            {
                ss.Remove(s);
            }

            ss.Compile();
            CError.Compare(ss.GlobalTypes.Count, 2, "Types Count after Remove"); //+1 for anyType
            CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type1, ns1)), true, "Contains1");
            CError.Compare(ss.GlobalTypes.Contains(new XmlQualifiedName(type2, ns2)), false, "Contains2");

            return;
        }
Esempio n. 23
0
        public void v11(object param0, object param1)
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();

            try
            {
                XmlSchema Schema1 = sc.Add(null, TestData._Root + param0.ToString()); // param as filename
                XmlSchema Schema2 = sc.Add(null, TestData._Root + param1.ToString()); // param as filename
                sc.Compile();
                CError.Compare(sc.Count, 2, "Count");
                sc.Remove(Schema2);
                sc.Compile();
                CError.Compare(sc.Count, 1, "Count");
                CError.Compare(sc.GlobalElements.Count, 2, "GlobalElems Count");
            }
            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;
        }
Esempio n. 25
0
        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;
        }
Esempio n. 26
0
        public void v51(object param0, object param1, object param2, object param3)
        {
            bWarningCallback = false;
            bErrorCallback = false;

            string mainFile = TestData._Root + param0.ToString();
            string include1 = TestData._Root + param1.ToString();
            string include2 = TestData._Root + param2.ToString();
            string xmlFile = TestData._Root + "bug382119.xml";
            bool IsImport = (bool)param3;

            XmlSchemaSet set1 = new XmlSchemaSet();
            set1.XmlResolver = new XmlUrlResolver();
            set1.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
            XmlSchema includedSchema = set1.Add(null, include1);
            set1.Compile();

            XmlSchemaSet set = new XmlSchemaSet();
            set.XmlResolver = new XmlUrlResolver();
            set.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
            XmlSchema mainSchema = set.Add(null, mainFile);
            set.Compile();

            _output.WriteLine("First validation ***************");
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas = set;
            XmlReader reader = XmlReader.Create(xmlFile, settings);
            while (reader.Read()) { }

            CError.Compare(bWarningCallback, false, "Warning count mismatch");
            CError.Compare(bErrorCallback, true, "Error count mismatch");

            if (IsImport == true)
                set.Remove(((XmlSchemaExternal)mainSchema.Includes[0]).Schema);
            _output.WriteLine("re-setting include");
            XmlSchema reParsedInclude = LoadSchema(include2, include1);
            ((XmlSchemaExternal)mainSchema.Includes[0]).Schema = reParsedInclude;

            _output.WriteLine("Calling reprocess");

            set.Reprocess(mainSchema);
            set.Compile();

            bWarningCallback = false;
            bErrorCallback = false;
            _output.WriteLine("Second validation ***************");
            settings.Schemas = set;
            reader = XmlReader.Create(xmlFile, settings);
            while (reader.Read()) { }

            CError.Compare(bWarningCallback, false, "Warning count mismatch");
            CError.Compare(bErrorCallback, false, "Error count mismatch");

            //Editing the include again
            _output.WriteLine("Re-adding include to set1");
            XmlSchema reParsedInclude2 = LoadSchema(include1, include1);
            set1.Remove(includedSchema);
            set1.Add(reParsedInclude2);
            set1.Compile();

            if (IsImport == true)
                set.Remove(((XmlSchemaExternal)mainSchema.Includes[0]).Schema);

            ((XmlSchemaExternal)mainSchema.Includes[0]).Schema = reParsedInclude2;
            set.Reprocess(mainSchema);
            set.Compile();

            bWarningCallback = false;
            bErrorCallback = false;

            _output.WriteLine("Third validation, Expecting errors ***************");
            settings.Schemas = set;
            reader = XmlReader.Create(xmlFile, settings);
            while (reader.Read()) { }

            CError.Compare(bWarningCallback, false, "Warning count mismatch");
            CError.Compare(bErrorCallback, true, "Error count mismatch");

            return;
        }
Esempio n. 27
0
        public void v6()
        {
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();

            try
            {
                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.Remove(Schema1);
                CError.Compare(sc.Count, 2, "Count");
                ICollection Col = sc.Schemas();
                CError.Compare(Col.Count, 2, "ICollection.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");
            }
            catch (Exception)
            {
                Assert.True(false);
            }
            return;
        }