XmlUrlResolverTests.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // System.Xml.XmlUrlResolver.cs
  3. //
  4. // Authors:
  5. // Atsushi Enomoto ([email protected])
  6. //
  7. // (C) 2003 Atsushi Enomoto
  8. //
  9. using System;
  10. using System.IO;
  11. using System.Xml;
  12. using NUnit.Framework;
  13. namespace MonoTests.System.Xml
  14. {
  15. [TestFixture]
  16. public class XmlUrlResolverTests : Assertion
  17. {
  18. XmlUrlResolver resolver;
  19. [SetUp]
  20. public void GetReady ()
  21. {
  22. resolver = new XmlUrlResolver ();
  23. }
  24. [Test]
  25. public void FileUri ()
  26. {
  27. Uri resolved = resolver.ResolveUri (null, "XmlFiles/xsd/xml.xsd");
  28. AssertEquals ("file", resolved.Scheme);
  29. Stream s = resolver.GetEntity (resolved, null, typeof (Stream)) as Stream;
  30. }
  31. [Test]
  32. public void FileUri2 ()
  33. {
  34. AssertEquals ("file://usr/local/src", resolver.ResolveUri (new Uri ("file://usr/local/src"), null).ToString ());
  35. AssertEquals ("file://usr/local/src", resolver.ResolveUri (new Uri ("file:///usr/local/src"), null).ToString ());
  36. }
  37. [Test]
  38. public void HttpUri ()
  39. {
  40. AssertEquals ("http://test.xml/", resolver.ResolveUri (null, "http://test.xml").ToString ());
  41. }
  42. [Test]
  43. public void HttpUri2 ()
  44. {
  45. AssertEquals ("http://go-mono.com/", resolver.ResolveUri (new Uri ("http://go-mono.com"), null).ToString ());
  46. }
  47. [Test]
  48. public void NullArgs ()
  49. {
  50. try {
  51. resolver.ResolveUri (null, null);
  52. Fail ("Should be error (MS.NET throws ArgumentException here).");
  53. } catch (Exception) {
  54. // OK
  55. }
  56. }
  57. }
  58. }