2 // System.Xml.XmlUrlResolver.cs
\r
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
\r
7 // (C) 2003 Atsushi Enomoto
\r
12 using NUnit.Framework;
\r
14 namespace MonoTests.System.Xml
\r
17 public class XmlUrlResolverTests : Assertion
\r
19 XmlUrlResolver resolver;
\r
22 public void GetReady ()
\r
24 resolver = new XmlUrlResolver ();
\r
28 public void FileUri ()
\r
30 Uri resolved = resolver.ResolveUri (null, "Test/XmlFiles/xsd/xml.xsd");
\r
31 AssertEquals ("file", resolved.Scheme);
\r
32 Stream s = resolver.GetEntity (resolved, null, typeof (Stream)) as Stream;
\r
36 [Category ("NotDotNet")]
\r
37 public void FileUri2 ()
\r
39 AssertEquals ("file://usr/local/src", resolver.ResolveUri (new Uri ("file://usr/local/src"), null).ToString ());
\r
40 // MS.NET returns the Uri.ToString() as
\r
41 // file://usr/local/src, but it is apparently
\r
42 // incorrect in the context of Unix path.
\r
43 AssertEquals ("file:///usr/local/src", resolver.ResolveUri (new Uri ("file:///usr/local/src"), null).ToString ());
\r
47 public void HttpUri ()
\r
49 AssertEquals ("http://test.xml/", resolver.ResolveUri (null, "http://test.xml").ToString ());
\r
53 public void HttpUri2 ()
\r
55 AssertEquals ("http://go-mono.com/", resolver.ResolveUri (new Uri ("http://go-mono.com"), null).ToString ());
\r
60 [Category ("NotDotNet")] // It should throw ArgumentNullException.
\r
62 [ExpectedException (typeof (ArgumentNullException))]
\r
63 public void ResolveUriWithNullArgs ()
\r
65 resolver.ResolveUri (null, null);
\r
66 Fail ("Should be error (MS.NET throws ArgumentException here).");
\r
69 // [Test] Uncomment if you want to test.
\r
70 public void GetEntityWithNullArgs ()
\r
72 Uri uri = new Uri ("http://www.go-mono.com/index.rss");
\r
73 resolver.GetEntity (uri, null, null);
\r
78 [ExpectedException (typeof (ArgumentException))]
\r
79 public void GetEntityWithRelativeFileUri ()
\r
81 resolver.GetEntity (new Uri ("file.txt", UriKind.Relative), null, typeof (Stream));
\r
86 [ExpectedException (typeof (XmlException))]
\r
87 public void GetEntityWithNonStreamReturnType ()
\r
89 resolver.GetEntity (new Uri ("http://www.go-mono.com/"), null, typeof (File));
\r