2004-01-03 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.XML / Test / System.Xml / XmlUrlResolverTests.cs
1 //\r
2 // System.Xml.XmlUrlResolver.cs\r
3 //\r
4 // Authors:\r
5 //      Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)\r
6 //\r
7 // (C) 2003 Atsushi Enomoto\r
8 //\r
9 using System;\r
10 using System.IO;\r
11 using System.Xml;\r
12 using NUnit.Framework;\r
13 \r
14 namespace MonoTests.System.Xml\r
15 {\r
16         [TestFixture]\r
17         public class XmlUrlResolverTests : Assertion\r
18         {\r
19                 XmlUrlResolver resolver;\r
20 \r
21                 [SetUp]\r
22                 public void GetReady ()\r
23                 {\r
24                         resolver = new XmlUrlResolver ();\r
25                 }\r
26 \r
27                 [Test]\r
28                 public void FileUri ()\r
29                 {\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
33                 }\r
34 \r
35                 [Test]\r
36                 public void FileUri2 ()\r
37                 {\r
38                         AssertEquals ("file://usr/local/src", resolver.ResolveUri (new Uri ("file://usr/local/src"), null).ToString ());\r
39                         AssertEquals ("file://usr/local/src", resolver.ResolveUri (new Uri ("file:///usr/local/src"), null).ToString ());\r
40                 }\r
41 \r
42                 [Test]\r
43                 public void HttpUri ()\r
44                 {\r
45                         AssertEquals ("http://test.xml/", resolver.ResolveUri (null, "http://test.xml").ToString ());\r
46                 }\r
47 \r
48                 [Test]\r
49                 public void HttpUri2 ()\r
50                 {\r
51                         AssertEquals ("http://go-mono.com/", resolver.ResolveUri (new Uri ("http://go-mono.com"), null).ToString ());\r
52                 }\r
53 \r
54                 [Test]\r
55                 [ExpectedException (typeof (NullReferenceException))]\r
56                 public void ResolveUriWithNullArgs ()\r
57                 {\r
58                         resolver.ResolveUri (null, null);\r
59                         Fail ("Should be error (MS.NET throws ArgumentException here).");\r
60                 }\r
61 \r
62 //              [Test] Uncomment if you want to test.\r
63                 public void GetEntityWithNullArgs ()\r
64                 {\r
65                         Uri uri = new Uri ("http://www.go-mono.com/index.rss");\r
66                         resolver.GetEntity (uri, null, null);\r
67                 }\r
68 \r
69                 [Test]\r
70                 [ExpectedException (typeof (ArgumentException))]\r
71                 public void GetEntityWithRelativeFileUri ()\r
72                 {\r
73                         resolver.GetEntity (new Uri ("file://file.txt"), null, typeof (Stream));\r
74                 }\r
75 \r
76                 [Test]\r
77                 [ExpectedException (typeof (XmlException))]\r
78                 public void GetEntityWithNonStreamReturnType ()\r
79                 {\r
80                         resolver.GetEntity (new Uri ("http://www.go-mono.com/"), null, typeof (File));\r
81                 }\r
82         }\r
83 }\r