**** Merged from MCS ****
[mono-project.git] / mcs / class / System.XML / Test / System.Xml / XmlUrlResolverTests.cs
blobf92d3da642998f08f57cde3a2f8435c605f713cd
1 //
2 // System.Xml.XmlUrlResolver.cs
3 //
4 // Authors:
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
6 //
7 // (C) 2003 Atsushi Enomoto
8 //
9 using System;
10 using System.IO;
11 using System.Xml;
12 using NUnit.Framework;
14 namespace MonoTests.System.Xml
16 [TestFixture]
17 public class XmlUrlResolverTests : Assertion
19 XmlUrlResolver resolver;
21 [SetUp]
22 public void GetReady ()
24 resolver = new XmlUrlResolver ();
27 [Test]
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;
35 [Test]
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 ());
45 [Test]
46 public void HttpUri ()
48 AssertEquals ("http://test.xml/", resolver.ResolveUri (null, "http://test.xml").ToString ());
51 [Test]
52 public void HttpUri2 ()
54 AssertEquals ("http://go-mono.com/", resolver.ResolveUri (new Uri ("http://go-mono.com"), null).ToString ());
57 [Test]
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);
72 [Test]
73 [ExpectedException (typeof (ArgumentException))]
74 public void GetEntityWithRelativeFileUri ()
76 resolver.GetEntity (new Uri ("file://file.txt"), null, typeof (Stream));
79 [Test]
80 [ExpectedException (typeof (XmlException))]
81 public void GetEntityWithNonStreamReturnType ()
83 resolver.GetEntity (new Uri ("http://www.go-mono.com/"), null, typeof (File));