Files
mono/mcs/class/System.XML/Test/System.Xml/XmlUrlResolverTests.cs
T
Atsushi Eno 3b434e9bea 2007-12-06 Atsushi Enomoto <[email protected]>
* XmlUrlResolver.cs : in net_2_0, use Uri.IsAbsoluteUri to filter
	  relative URIs out.

	* XmlUrlResolverTests.cs : fixed test; file://file.txt is to access
	  such a server whose (domain) name is "file.txt", which is actually
	  an absolute URI. Remove "regression" in the nunit test.


svn path=/trunk/mcs/; revision=90794
2007-12-06 06:32:05 +00:00

93 lines
2.3 KiB
C#

//
// System.Xml.XmlUrlResolver.cs
//
// Authors:
// Atsushi Enomoto ([email protected])
//
// (C) 2003 Atsushi Enomoto
//
using System;
using System.IO;
using System.Xml;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlUrlResolverTests : Assertion
{
XmlUrlResolver resolver;
[SetUp]
public void GetReady ()
{
resolver = new XmlUrlResolver ();
}
[Test]
public void FileUri ()
{
Uri resolved = resolver.ResolveUri (null, "Test/XmlFiles/xsd/xml.xsd");
AssertEquals ("file", resolved.Scheme);
Stream s = resolver.GetEntity (resolved, null, typeof (Stream)) as Stream;
}
[Test]
[Category ("NotDotNet")]
public void FileUri2 ()
{
AssertEquals ("file://usr/local/src", resolver.ResolveUri (new Uri ("file://usr/local/src"), null).ToString ());
// MS.NET returns the Uri.ToString() as
// file://usr/local/src, but it is apparently
// incorrect in the context of Unix path.
AssertEquals ("file:///usr/local/src", resolver.ResolveUri (new Uri ("file:///usr/local/src"), null).ToString ());
}
[Test]
public void HttpUri ()
{
AssertEquals ("http://test.xml/", resolver.ResolveUri (null, "http://test.xml").ToString ());
}
[Test]
public void HttpUri2 ()
{
AssertEquals ("http://go-mono.com/", resolver.ResolveUri (new Uri ("http://go-mono.com"), null).ToString ());
}
[Test]
#if !NET_2_0
[Category ("NotDotNet")] // It should throw ArgumentNullException.
#endif
[ExpectedException (typeof (ArgumentNullException))]
public void ResolveUriWithNullArgs ()
{
resolver.ResolveUri (null, null);
Fail ("Should be error (MS.NET throws ArgumentException here).");
}
// [Test] Uncomment if you want to test.
public void GetEntityWithNullArgs ()
{
Uri uri = new Uri ("http://www.go-mono.com/index.rss");
resolver.GetEntity (uri, null, null);
}
#if NET_2_0
[Test]
[ExpectedException (typeof (ArgumentException))]
public void GetEntityWithRelativeFileUri ()
{
resolver.GetEntity (new Uri ("file.txt", UriKind.Relative), null, typeof (Stream));
}
#endif
[Test]
[ExpectedException (typeof (XmlException))]
public void GetEntityWithNonStreamReturnType ()
{
resolver.GetEntity (new Uri ("http://www.go-mono.com/"), null, typeof (File));
}
}
}