XmlSchemaCollectionTests.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // System.Xml.XmlSchemaCollectionTests.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C) 2002 Atsushi Enomoto
  8. //
  9. using System;
  10. using System.IO;
  11. using System.Xml;
  12. using System.Xml.Schema;
  13. using NUnit.Framework;
  14. namespace MonoTests.System.Xml
  15. {
  16. [TestFixture]
  17. public class XmlSchemaCollectionTests : Assertion
  18. {
  19. private XmlSchema GetSchema (string path)
  20. {
  21. return XmlSchema.Read (new XmlTextReader (path), null);
  22. }
  23. private XmlQualifiedName QName (string name, string ns)
  24. {
  25. return new XmlQualifiedName (name, ns);
  26. }
  27. [Test]
  28. public void TestAdd ()
  29. {
  30. XmlSchemaCollection col = new XmlSchemaCollection ();
  31. XmlSchema schema = new XmlSchema ();
  32. XmlSchemaElement elem = new XmlSchemaElement ();
  33. elem.Name = "foo";
  34. schema.Items.Add (elem);
  35. schema.TargetNamespace = "urn:foo";
  36. col.Add (schema);
  37. col.Add (schema); // No problem !?
  38. XmlSchema schema2 = new XmlSchema ();
  39. schema2.Items.Add (elem);
  40. schema2.TargetNamespace = "urn:foo";
  41. col.Add (schema2); // No problem !!
  42. schema.Compile (null);
  43. col.Add (schema);
  44. col.Add (schema); // Still no problem !!!
  45. schema2.Compile (null);
  46. col.Add (schema2);
  47. schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
  48. schema.Compile (null);
  49. col.Add (schema);
  50. schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
  51. schema2.Compile (null);
  52. col.Add (schema2);
  53. }
  54. [Test]
  55. public void TestAddDoesCompilation ()
  56. {
  57. XmlSchema schema = new XmlSchema ();
  58. Assert (!schema.IsCompiled);
  59. XmlSchemaCollection col = new XmlSchemaCollection ();
  60. col.Add (schema);
  61. Assert (schema.IsCompiled);
  62. }
  63. }
  64. }