**** Merged from MCS ****
[mono-project.git] / mcs / class / System.XML / Test / System.Xml.Schema / XmlSchemaSetTests.cs
blob3085e180a97ce304eb1c638510874841755892b8
1 //
2 // System.Xml.XmlSchemaSetTests.cs
3 //
4 // Author:
5 // Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // (C) 2004 Novell Inc.
8 //
9 #if NET_2_0
11 using System;
12 using System.Collections;
13 using System.IO;
14 using System.Xml;
15 using System.Xml.Schema;
16 using NUnit.Framework;
18 namespace MonoTests.System.Xml
20 [TestFixture]
21 public class XmlSchemaSetTests
23 [Test]
24 public void Add ()
26 XmlSchemaSet ss = new XmlSchemaSet ();
27 XmlDocument doc = new XmlDocument ();
28 doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
29 ss.Add (null, new XmlNodeReader (doc)); // null targetNamespace
30 ss.Compile ();
32 // same document, different targetNamespace
33 ss.Add ("ab", new XmlNodeReader (doc));
35 // Add(null, xmlReader) -> targetNamespace in the schema
36 doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo' />");
37 ss.Add (null, new XmlNodeReader (doc));
39 Assert.AreEqual (3, ss.Count);
41 bool chameleon = false;
42 bool ab = false;
43 bool urnfoo = false;
45 foreach (XmlSchema schema in ss.Schemas ()) {
46 if (schema.TargetNamespace == null)
47 chameleon = true;
48 else if (schema.TargetNamespace == "ab")
49 ab = true;
50 else if (schema.TargetNamespace == "urn:foo")
51 urnfoo = true;
53 Assert.IsTrue (chameleon, "chameleon schema missing");
54 Assert.IsTrue (ab, "target-remapped schema missing");
55 Assert.IsTrue (urnfoo, "target specified in the schema ignored");
58 [Test]
59 [Ignore ("This behavior might be changed, since Add(XmlSchema) does not throw any exceptions, while this does.")]
60 [ExpectedException (typeof (ArgumentException))]
61 public void AddTwice ()
63 XmlSchemaSet ss = new XmlSchemaSet ();
64 XmlDocument doc = new XmlDocument ();
65 doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
66 ss.Add ("ab", new XmlNodeReader (doc));
67 ss.Add ("ab", new XmlNodeReader (doc));
71 #endif