2 // System.Xml.XmlSchemaSetTests.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (C) 2004 Novell Inc.
12 using System.Collections;
15 using System.Xml.Schema;
16 using NUnit.Framework;
18 namespace MonoTests.System.Xml
21 public class XmlSchemaSetTests
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
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;
45 foreach (XmlSchema schema in ss.Schemas ()) {
46 if (schema.TargetNamespace == null)
48 else if (schema.TargetNamespace == "ab")
50 else if (schema.TargetNamespace == "urn:foo")
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");
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));