[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.XML / Test / System.Xml.Schema / XmlSchemaCollectionTests.cs
blob9491e21a427754b96e12189b2e5ab93d77107a49
1 //
2 // System.Xml.XmlSchemaCollectionTests.cs
3 //
4 // Author:
5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
6 //
7 // (C) 2002 Atsushi Enomoto
8 //
10 using System;
11 using System.Globalization;
12 using System.IO;
13 using System.Xml;
14 using System.Xml.Schema;
15 using NUnit.Framework;
17 using MonoTests.Helpers;
19 namespace MonoTests.System.Xml
21 [TestFixture]
22 public class XmlSchemaCollectionTests
24 private XmlSchema GetSchema (string resourceName)
26 return XmlSchema.Read (new XmlTextReader (TestResourceHelper.GetFullPathOfResource (resourceName)), null);
29 private XmlQualifiedName QName (string name, string ns)
31 return new XmlQualifiedName (name, ns);
34 [Test]
35 public void TestAdd ()
37 XmlSchemaCollection col = new XmlSchemaCollection ();
38 XmlSchema schema = new XmlSchema ();
39 XmlSchemaElement elem = new XmlSchemaElement ();
40 elem.Name = "foo";
41 schema.Items.Add (elem);
42 schema.TargetNamespace = "urn:foo";
43 col.Add (schema);
44 col.Add (schema); // No problem !?
46 XmlSchema schema2 = new XmlSchema ();
47 schema2.Items.Add (elem);
48 schema2.TargetNamespace = "urn:foo";
49 col.Add (schema2); // No problem !!
51 schema.Compile (null);
52 col.Add (schema);
53 col.Add (schema); // Still no problem !!!
55 schema2.Compile (null);
56 col.Add (schema2);
58 schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
59 schema.Compile (null);
60 col.Add (schema);
62 schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
63 schema2.Compile (null);
64 col.Add (schema2);
67 [Test]
68 public void TestAddDoesCompilation ()
70 XmlSchema schema = new XmlSchema ();
71 Assert.IsFalse (schema.IsCompiled);
72 XmlSchemaCollection col = new XmlSchemaCollection ();
73 col.Add (schema);
74 Assert.IsTrue (schema.IsCompiled);
77 [Test] // bug #75126
78 public void TestGetEnumerator ()
80 new XmlSchemaCollection().GetEnumerator();
83 [Test] // bug #78220
84 public void TestCompile ()
86 string schemaFragment1 = string.Format (CultureInfo.InvariantCulture,
87 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
88 "<xs:schema xmlns:tns=\"NSDate\" elementFormDefault=\"qualified\" targetNamespace=\"NSDate\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
89 " <xs:import namespace=\"NSStatus\" />{0}" +
90 " <xs:element name=\"trans\" type=\"tns:TranslationStatus\" />{0}" +
91 " <xs:complexType name=\"TranslationStatus\">{0}" +
92 " <xs:simpleContent>{0}" +
93 " <xs:extension xmlns:q1=\"NSStatus\" base=\"q1:StatusType\">{0}" +
94 " <xs:attribute name=\"Language\" type=\"xs:int\" use=\"required\" />{0}" +
95 " </xs:extension>{0}" +
96 " </xs:simpleContent>{0}" +
97 " </xs:complexType>{0}" +
98 "</xs:schema>", Environment.NewLine);
100 string schemaFragment2 = string.Format (CultureInfo.InvariantCulture,
101 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
102 "<xs:schema xmlns:tns=\"NSStatus\" elementFormDefault=\"qualified\" targetNamespace=\"NSStatus\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
103 " <xs:simpleType name=\"StatusType\">{0}" +
104 " <xs:restriction base=\"xs:string\">{0}" +
105 " <xs:enumeration value=\"Untouched\" />{0}" +
106 " <xs:enumeration value=\"Touched\" />{0}" +
107 " <xs:enumeration value=\"Complete\" />{0}" +
108 " <xs:enumeration value=\"None\" />{0}" +
109 " </xs:restriction>{0}" +
110 " </xs:simpleType>{0}" +
111 "</xs:schema>", Environment.NewLine);
113 XmlSchema schema1 = XmlSchema.Read (new StringReader (schemaFragment1), null);
114 XmlSchema schema2 = XmlSchema.Read (new StringReader (schemaFragment2), null);
116 XmlSchemaCollection schemas = new XmlSchemaCollection ();
117 schemas.Add (schema2);
118 schemas.Add (schema1);
120 Assert.IsTrue (schema1.IsCompiled, "#1");
121 Assert.IsTrue (schema2.IsCompiled, "#2");