2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.XML / Test / System.Xml.Schema / XmlSchemaCollectionTests.cs
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 //
9
10 using System;
11 using System.IO;
12 using System.Xml;
13 using System.Xml.Schema;
14 using NUnit.Framework;
15
16 namespace MonoTests.System.Xml
17 {
18         [TestFixture]
19         public class XmlSchemaCollectionTests : Assertion
20         {
21                 private XmlSchema GetSchema (string path)
22                 {
23                         return XmlSchema.Read (new XmlTextReader (path), null);
24                 }
25
26                 private XmlQualifiedName QName (string name, string ns)
27                 {
28                         return new XmlQualifiedName (name, ns);
29                 }
30
31                 [Test]
32                 public void TestAdd ()
33                 {
34                         XmlSchemaCollection col = new XmlSchemaCollection ();
35                         XmlSchema schema = new XmlSchema ();
36                         XmlSchemaElement elem = new XmlSchemaElement ();
37                         elem.Name = "foo";
38                         schema.Items.Add (elem);
39                         schema.TargetNamespace = "urn:foo";
40                         col.Add (schema);
41                         col.Add (schema);       // No problem !?
42
43                         XmlSchema schema2 = new XmlSchema ();
44                         schema2.Items.Add (elem);
45                         schema2.TargetNamespace = "urn:foo";
46                         col.Add (schema2);      // No problem !!
47
48                         schema.Compile (null);
49                         col.Add (schema);
50                         col.Add (schema);       // Still no problem !!!
51
52                         schema2.Compile (null);
53                         col.Add (schema2);
54
55                         schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
56                         schema.Compile (null);
57                         col.Add (schema);
58
59                         schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
60                         schema2.Compile (null);
61                         col.Add (schema2);
62                 }
63
64                 [Test]\r
65                 public void TestAddDoesCompilation ()\r
66                 {\r
67                         XmlSchema schema = new XmlSchema ();\r
68                         Assert (!schema.IsCompiled);\r
69                         XmlSchemaCollection col = new XmlSchemaCollection ();\r
70                         col.Add (schema);\r
71                         Assert (schema.IsCompiled);\r
72                 }\r
73         }
74 }