XmlEntityTests.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // System.Xml.XmlEntityTests.cs
  3. //
  4. // Author: Atsushi Enomoto ([email protected])
  5. //
  6. // (C) 2003 Atsushi Enomoto
  7. //
  8. using System;
  9. using System.Xml;
  10. using NUnit.Framework;
  11. namespace MonoTests.System.Xml
  12. {
  13. [TestFixture]
  14. public class XmlEntityTests : Assertion
  15. {
  16. XmlDocument document;
  17. XmlDocumentType docType;
  18. [SetUp]
  19. public void GetReady ()
  20. {
  21. document = new XmlDocument ();
  22. docType = document.CreateDocumentType ("book", null, null, "<!ELEMENT book ANY>");
  23. document.AppendChild (docType);
  24. }
  25. [Test]
  26. public void TestValue ()
  27. {
  28. XmlTextReader xtr = new XmlTextReader ("<!DOCTYPE x:foo [<!ENTITY foo 'fooent'><!ENTITY bar 'test &foo;'>]><x:foo xmlns:x='hoge' />", XmlNodeType.Document, null);
  29. document.Load (xtr);
  30. xtr.Close ();
  31. docType = document.DocumentType;
  32. AssertEquals (2, docType.Entities.Count);
  33. XmlEntity foo = docType.Entities.Item (0) as XmlEntity;
  34. XmlEntity bar = docType.Entities.Item (1) as XmlEntity;
  35. AssertEquals ("foo", foo.Name);
  36. AssertNull (bar.Value);
  37. AssertEquals (1, foo.ChildNodes.Count);
  38. AssertEquals ("bar", bar.Name);
  39. AssertNull (bar.Value);
  40. AssertEquals (1, foo.ChildNodes.Count);
  41. }
  42. }
  43. }