2 // System.Xml.XmlUrlResolver.cs
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
7 // (C) 2003 Atsushi Enomoto
12 using NUnit
.Framework
;
14 namespace MonoTests
.System
.Xml
17 public class XmlUrlResolverTests
: Assertion
19 XmlUrlResolver resolver
;
22 public void GetReady ()
24 resolver
= new XmlUrlResolver ();
28 public void FileUri ()
30 Uri resolved
= resolver
.ResolveUri (null, "Test/XmlFiles/xsd/xml.xsd");
31 AssertEquals ("file", resolved
.Scheme
);
32 Stream s
= resolver
.GetEntity (resolved
, null, typeof (Stream
)) as Stream
;
36 public void FileUri2 ()
38 AssertEquals ("file://usr/local/src", resolver
.ResolveUri (new Uri ("file://usr/local/src"), null).ToString ());
39 // MS.NET returns the Uri.ToString() as
40 // file://usr/local/src, but it is apparently
41 // incorrect in the context of Unix path.
42 AssertEquals ("file:///usr/local/src", resolver
.ResolveUri (new Uri ("file:///usr/local/src"), null).ToString ());
46 public void HttpUri ()
48 AssertEquals ("http://test.xml/", resolver
.ResolveUri (null, "http://test.xml").ToString ());
52 public void HttpUri2 ()
54 AssertEquals ("http://go-mono.com/", resolver
.ResolveUri (new Uri ("http://go-mono.com"), null).ToString ());
58 [ExpectedException (typeof (NullReferenceException
))]
59 public void ResolveUriWithNullArgs ()
61 resolver
.ResolveUri (null, null);
62 Fail ("Should be error (MS.NET throws ArgumentException here).");
65 // [Test] Uncomment if you want to test.
66 public void GetEntityWithNullArgs ()
68 Uri uri
= new Uri ("http://www.go-mono.com/index.rss");
69 resolver
.GetEntity (uri
, null, null);
73 [ExpectedException (typeof (ArgumentException
))]
74 public void GetEntityWithRelativeFileUri ()
76 resolver
.GetEntity (new Uri ("file://file.txt"), null, typeof (Stream
));
80 [ExpectedException (typeof (XmlException
))]
81 public void GetEntityWithNonStreamReturnType ()
83 resolver
.GetEntity (new Uri ("http://www.go-mono.com/"), null, typeof (File
));