System.Xml.Tests.TC_SchemaSet_Imports.v207 C# (CSharp) Méthode

v207() private méthode

private v207 ( ) : void
Résultat void
        public void v207()
        {
            bool found = false;
            XmlSchemaSet sc = new XmlSchemaSet();
            sc.XmlResolver = new XmlUrlResolver();
            XmlSchema parent = sc.Add(null, Path.Combine(TestData._Root, "import_v10_a.xsd"));
            CError.Compare(sc.IsCompiled, false, "AddIsCompiled");
            CError.Compare(sc.Count, 3, "AddCount");

            sc.Compile();
            CError.Compare(sc.Count, 3, "CompileCount");
            CError.Compare(sc.IsCompiled, true, "CompileIsCompiled");

            sc.Reprocess(parent);
            CError.Compare(sc.IsCompiled, false, "ReprocessIsCompiled");
            CError.Compare(sc.Count, 3, "ReprocessCount");

            XmlSchema sch_B = sc.Add(null, Path.Combine(TestData._Root, "import_v10_b.xsd")); // should be already present in the set
            sc.Add(null, Path.Combine(TestData._Root, "import_v10_c.xsd"));				   // should be already present in the set
            CError.Compare(sc.Count, 3, "Count");
            CError.Compare(sc.IsCompiled, false, "IsCompiled");

            sc.Compile();
            CError.Compare(sc.Count, 3, "CompileCount");
            CError.Compare(sc.IsCompiled, true, "CompileIsCompiled");

            sc.Reprocess(sch_B);
            CError.Compare(sc.IsCompiled, false, "ReprocessIsCompiled");
            CError.Compare(sc.Count, 3, "ReprocessCount");

            // check that schema is present in parent.Includes and its NS correct.
            foreach (XmlSchemaImport imp in parent.Includes)
                if (imp.SchemaLocation.Equals("import_v10_b.xsd") && imp.Schema.TargetNamespace == null)
                    found = true;

            if (!found) Assert.True(false);

            // check that schema C in sch_b.Includes and its NS correct.
            foreach (XmlSchemaImport imp in sch_B.Includes)
                if (imp.SchemaLocation.Equals("import_v10_c.xsd") && imp.Schema.TargetNamespace.Equals("ns-c"))
                    found = true;

            if (!found) Assert.True(false);

            // try adding no ns schema with an ns
            sch_B = sc.Add("ns-b", Path.Combine(TestData._Root, "import_v10_b.xsd"));
            CError.Compare(sc.Count, 4, "Count");

            sc.Compile();
            CError.Compare(sc.Count, 4, "CompileCount");
            CError.Compare(sc.IsCompiled, true, "CompileIsCompiled");

            sc.Reprocess(sch_B);
            CError.Compare(sc.IsCompiled, false, "ReprocessIsCompiled");
            CError.Compare(sc.Count, 4, "ReprocessCount");
            return;
        }