* UriTest.cs: Added test for Fragment with relative URI. Fixed line
authorGert Driesen <drieseng@users.sourceforge.net>
Wed, 26 Sep 2007 20:22:43 +0000 (20:22 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Wed, 26 Sep 2007 20:22:43 +0000 (20:22 -0000)
endings.
* UriTest2.cs: Fixed line endings.
* UriTest3.cs: Added test for MakeRelativeUri. Added tests for
AbsoluteUri, PathAndQuery, Query and Scheme with relative URI.

svn path=/trunk/mcs/; revision=86443

mcs/class/System/Test/System/ChangeLog
mcs/class/System/Test/System/UriTest.cs
mcs/class/System/Test/System/UriTest2.cs
mcs/class/System/Test/System/UriTest3.cs

index d60203787b166e41c7ce1bf03554755857cd4c5c..f0bd95e67a04ee22e2d2a3f805fd424e242aa52d 100644 (file)
@@ -1,3 +1,11 @@
+2007-09-26  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * UriTest.cs: Added test for Fragment with relative URI. Fixed line
+       endings.
+       * UriTest2.cs: Fixed line endings.
+       * UriTest3.cs: Added test for MakeRelativeUri. Added tests for
+       AbsoluteUri, PathAndQuery, Query and Scheme with relative URI.
+
 2007-09-06  Marek Habersack  <mhabersack@novell.com>
 
        * UriTypeConverterTest.cs: Mono on Windows treats /Uri.txt URIs as
index e5307ebc71250246dfa239d71ed182bfff85a1f1..5efae863af2a8c1f42dadedd9ae0ed62f87681e1 100644 (file)
@@ -158,7 +158,7 @@ namespace MonoTests.System
                        AssertEquals ("#rel9", "http://www.contoso.com/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
 #else
                        AssertEquals ("#rel9", "http://www.contoso.com/../foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
-#endif\r
+#endif
                        uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "./foo/bar/Hello World.htm?x=0:8", false);
                        AssertEquals ("#rel10", "http://www.contoso.com/xxx/yyy/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri);
 
@@ -180,60 +180,60 @@ namespace MonoTests.System
                        AssertEquals ("#rel34", uri.OriginalString, "relative");
                        Assert ("#rel35", !uri.UserEscaped);
 #endif
-               }\r
-\r
-               [Test]\r
-               public void Constructor_DualHostPort ()\r
-               {\r
-                       string relative = "foo:8080/bar/Hello World.htm";\r
-                       Uri uri = new Uri (new Uri("http://www.contoso.com"), relative, false);\r
-                       AssertEquals ("AbsolutePath", "8080/bar/Hello%20World.htm", uri.AbsolutePath);\r
-                       AssertEquals ("AbsoluteUri", "foo:8080/bar/Hello%20World.htm", uri.AbsoluteUri);\r
-                       AssertEquals ("Authority", String.Empty, uri.Authority);\r
-                       AssertEquals ("Fragment", String.Empty, uri.Fragment);\r
-                       AssertEquals ("Host", String.Empty, uri.Host);\r
-                       AssertEquals ("PathAndQuery", "8080/bar/Hello%20World.htm", uri.PathAndQuery);\r
-                       AssertEquals ("Port", -1, uri.Port);\r
-                       AssertEquals ("Query", String.Empty, uri.Query);\r
-                       AssertEquals ("Scheme", "foo", uri.Scheme);\r
-                       AssertEquals ("Query", String.Empty, uri.UserInfo);\r
-\r
-                       AssertEquals ("Segments[0]", "8080/", uri.Segments[0]);\r
-                       AssertEquals ("Segments[1]", "bar/", uri.Segments[1]);\r
-                       AssertEquals ("Segments[2]", "Hello%20World.htm", uri.Segments[2]);\r
-\r
-                       Assert ("IsDefaultPort", uri.IsDefaultPort);\r
-                       Assert ("IsFile", !uri.IsFile);\r
-                       Assert ("IsLoopback", !uri.IsLoopback);\r
-                       Assert ("IsUnc", !uri.IsUnc);\r
-                       Assert ("UserEscaped", !uri.UserEscaped);\r
-#if NET_2_0\r
-                       AssertEquals ("HostNameType", UriHostNameType.Unknown, uri.HostNameType);\r
-                       Assert ("IsAbsoluteUri", uri.IsAbsoluteUri);\r
+               }
+
+               [Test]
+               public void Constructor_DualHostPort ()
+               {
+                       string relative = "foo:8080/bar/Hello World.htm";
+                       Uri uri = new Uri (new Uri("http://www.contoso.com"), relative, false);
+                       AssertEquals ("AbsolutePath", "8080/bar/Hello%20World.htm", uri.AbsolutePath);
+                       AssertEquals ("AbsoluteUri", "foo:8080/bar/Hello%20World.htm", uri.AbsoluteUri);
+                       AssertEquals ("Authority", String.Empty, uri.Authority);
+                       AssertEquals ("Fragment", String.Empty, uri.Fragment);
+                       AssertEquals ("Host", String.Empty, uri.Host);
+                       AssertEquals ("PathAndQuery", "8080/bar/Hello%20World.htm", uri.PathAndQuery);
+                       AssertEquals ("Port", -1, uri.Port);
+                       AssertEquals ("Query", String.Empty, uri.Query);
+                       AssertEquals ("Scheme", "foo", uri.Scheme);
+                       AssertEquals ("Query", String.Empty, uri.UserInfo);
+
+                       AssertEquals ("Segments[0]", "8080/", uri.Segments[0]);
+                       AssertEquals ("Segments[1]", "bar/", uri.Segments[1]);
+                       AssertEquals ("Segments[2]", "Hello%20World.htm", uri.Segments[2]);
+
+                       Assert ("IsDefaultPort", uri.IsDefaultPort);
+                       Assert ("IsFile", !uri.IsFile);
+                       Assert ("IsLoopback", !uri.IsLoopback);
+                       Assert ("IsUnc", !uri.IsUnc);
+                       Assert ("UserEscaped", !uri.UserEscaped);
+#if NET_2_0
+                       AssertEquals ("HostNameType", UriHostNameType.Unknown, uri.HostNameType);
+                       Assert ("IsAbsoluteUri", uri.IsAbsoluteUri);
                        AssertEquals ("OriginalString", relative, uri.OriginalString);
 #else
-                       AssertEquals ("HostNameType", UriHostNameType.Basic, uri.HostNameType);\r
-#endif\r
-               }\r
-\r
-               [Test]\r
-#if NET_2_0\r
-               [ExpectedException (typeof (ArgumentNullException))]\r
-#else\r
-               [ExpectedException (typeof (NullReferenceException))]\r
-#endif\r
-               public void Constructor_NullStringBool ()\r
-               {\r
-                       new Uri (null, "http://www.contoso.com/index.htm", false);\r
-               }\r
-\r
-               [Test]\r
-#if ONLY_1_1\r
-               [ExpectedException (typeof (NullReferenceException))]\r
-#endif\r
-               public void Constructor_UriNullBool ()\r
-               {\r
-                       new Uri (new Uri ("http://www.contoso.com"), null, false);\r
+                       AssertEquals ("HostNameType", UriHostNameType.Basic, uri.HostNameType);
+#endif
+               }
+
+               [Test]
+#if NET_2_0
+               [ExpectedException (typeof (ArgumentNullException))]
+#else
+               [ExpectedException (typeof (NullReferenceException))]
+#endif
+               public void Constructor_NullStringBool ()
+               {
+                       new Uri (null, "http://www.contoso.com/index.htm", false);
+               }
+
+               [Test]
+#if ONLY_1_1
+               [ExpectedException (typeof (NullReferenceException))]
+#endif
+               public void Constructor_UriNullBool ()
+               {
+                       new Uri (new Uri ("http://www.contoso.com"), null, false);
                }
 
                // regression for bug #47573
@@ -255,22 +255,22 @@ namespace MonoTests.System
                        AssertEquals ("#6", "?q=r;.%20a", u.Query);
                }
 
-#if NET_2_0\r
-               [Test]\r
-               [ExpectedException (typeof (UriFormatException))]\r
+#if NET_2_0
+               [Test]
+               [ExpectedException (typeof (UriFormatException))]
                public void RelativeCtor_11_Crasher ()
-               {\r
-                       Uri b = new Uri ("http://a/b/c/d;p?q");\r
-                       // this causes crash under MS.NET 1.1\r
-                       AssertEquals ("g:h", "g:h", new Uri (b, "g:h").ToString ());\r
+               {
+                       Uri b = new Uri ("http://a/b/c/d;p?q");
+                       // this causes crash under MS.NET 1.1
+                       AssertEquals ("g:h", "g:h", new Uri (b, "g:h").ToString ());
                }
-#endif\r
-\r
-               [Test]\r
-               [ExpectedException (typeof (UriFormatException))]\r
-               public void Bad_IPv6 ()\r
-               {\r
-                       new Uri ("http://0:0:0:0::127.1.2.3]/");\r
+#endif
+
+               [Test]
+               [ExpectedException (typeof (UriFormatException))]
+               public void Bad_IPv6 ()
+               {
+                       new Uri ("http://0:0:0:0::127.1.2.3]/");
                }
 
                [Test]
@@ -282,186 +282,186 @@ namespace MonoTests.System
                        // doesn't (but should) fail under 1.x
                        AssertEquals ("#1", "file:///", new Uri ("file:///").ToString ());
                        AssertEquals ("#2", "file:///", new Uri ("file://").ToString ());
-               }\r
-\r
-               [Test]\r
+               }
+
+               [Test]
 #if ONLY_1_1
                [Category ("NotWorking")]
-#endif\r
-               public void LeadingSlashes_BadResultsOn1x ()\r
-               {\r
-                       // strange behaviours of 1.x - it's probably not worth to fix it\r
-                       // on Mono as 2.0 has been fixed\r
-                       Uri u = new Uri ("file:///foo/bar");\r
-#if NET_2_0\r
-                       AssertEquals ("#3a", String.Empty, u.Host);\r
-                       AssertEquals ("#3b", UriHostNameType.Basic, u.HostNameType);\r
-                       AssertEquals ("#3c", "file:///foo/bar", u.ToString ());\r
-                       AssertEquals ("#3d", false, u.IsUnc);\r
+#endif
+               public void LeadingSlashes_BadResultsOn1x ()
+               {
+                       // strange behaviours of 1.x - it's probably not worth to fix it
+                       // on Mono as 2.0 has been fixed
+                       Uri u = new Uri ("file:///foo/bar");
+#if NET_2_0
+                       AssertEquals ("#3a", String.Empty, u.Host);
+                       AssertEquals ("#3b", UriHostNameType.Basic, u.HostNameType);
+                       AssertEquals ("#3c", "file:///foo/bar", u.ToString ());
+                       AssertEquals ("#3d", false, u.IsUnc);
 #else
                        // 1.x misinterpret the first path element as the host name
-                       AssertEquals ("#3a", "foo", u.Host);\r
-                       AssertEquals ("#3b", UriHostNameType.Dns, u.HostNameType);\r
+                       AssertEquals ("#3a", "foo", u.Host);
+                       AssertEquals ("#3b", UriHostNameType.Dns, u.HostNameType);
                        AssertEquals ("#3c", "file://foo/bar", u.ToString ());
                        AssertEquals ("#3d", true, u.IsUnc);
-#endif\r
-                       u = new Uri ("mailto:/foo");\r
-#if NET_2_0\r
-                       AssertEquals ("#13a", String.Empty, u.Host);\r
-                       AssertEquals ("#13b", UriHostNameType.Basic, u.HostNameType);\r
-                       AssertEquals ("#13c", "mailto:/foo", u.ToString ());\r
+#endif
+                       u = new Uri ("mailto:/foo");
+#if NET_2_0
+                       AssertEquals ("#13a", String.Empty, u.Host);
+                       AssertEquals ("#13b", UriHostNameType.Basic, u.HostNameType);
+                       AssertEquals ("#13c", "mailto:/foo", u.ToString ());
 #else
                        // 1.x misinterpret the first path element as the host name
-                       AssertEquals ("#13a", "foo", u.Host);\r
-                       AssertEquals ("#13b", UriHostNameType.Dns, u.HostNameType);\r
-                       AssertEquals ("#13c", "mailto:foo", u.ToString ());\r
-#endif\r
-                       u = new Uri ("mailto://foo");\r
-#if NET_2_0\r
-                       AssertEquals ("#14a", String.Empty, u.Host);\r
-                       AssertEquals ("#14b", UriHostNameType.Basic, u.HostNameType);\r
-                       AssertEquals ("#14c", "mailto://foo", u.ToString ());\r
+                       AssertEquals ("#13a", "foo", u.Host);
+                       AssertEquals ("#13b", UriHostNameType.Dns, u.HostNameType);
+                       AssertEquals ("#13c", "mailto:foo", u.ToString ());
+#endif
+                       u = new Uri ("mailto://foo");
+#if NET_2_0
+                       AssertEquals ("#14a", String.Empty, u.Host);
+                       AssertEquals ("#14b", UriHostNameType.Basic, u.HostNameType);
+                       AssertEquals ("#14c", "mailto://foo", u.ToString ());
 #else
                        // 1.x misinterpret the first path element as the host name
-                       AssertEquals ("#14a", "foo", u.Host);\r
-                       AssertEquals ("#14b", UriHostNameType.Dns, u.HostNameType);\r
-                       AssertEquals ("#14c", "mailto://foo/", u.ToString ());\r
-#endif\r
-                       u = new Uri ("news:/");\r
-                       AssertEquals ("#18a", String.Empty, u.Host);\r
-#if NET_2_0\r
-                       AssertEquals ("#18b", UriHostNameType.Unknown, u.HostNameType);\r
-                       AssertEquals ("#18c", "news:/", u.ToString ());\r
-                       AssertEquals ("#18d", "/", u.AbsolutePath);\r
-                       AssertEquals ("#18e", "news:/", u.AbsoluteUri);\r
+                       AssertEquals ("#14a", "foo", u.Host);
+                       AssertEquals ("#14b", UriHostNameType.Dns, u.HostNameType);
+                       AssertEquals ("#14c", "mailto://foo/", u.ToString ());
+#endif
+                       u = new Uri ("news:/");
+                       AssertEquals ("#18a", String.Empty, u.Host);
+#if NET_2_0
+                       AssertEquals ("#18b", UriHostNameType.Unknown, u.HostNameType);
+                       AssertEquals ("#18c", "news:/", u.ToString ());
+                       AssertEquals ("#18d", "/", u.AbsolutePath);
+                       AssertEquals ("#18e", "news:/", u.AbsoluteUri);
 #else
                        AssertEquals ("#18b", UriHostNameType.Basic, u.HostNameType);
-                       AssertEquals ("#18c", "news:", u.ToString ());\r
-                       AssertEquals ("#18d", String.Empty, u.AbsolutePath);\r
-                       AssertEquals ("#18e", "news:", u.AbsoluteUri);\r
-#endif\r
-                       u = new Uri ("news:/foo");\r
-                       AssertEquals ("#19a", String.Empty, u.Host);\r
-#if NET_2_0\r
-                       AssertEquals ("#19b", UriHostNameType.Unknown, u.HostNameType);\r
-                       AssertEquals ("#19c", "news:/foo", u.ToString ());\r
-                       AssertEquals ("#19d", "/foo", u.AbsolutePath);\r
-                       AssertEquals ("#19e", "news:/foo", u.AbsoluteUri);\r
+                       AssertEquals ("#18c", "news:", u.ToString ());
+                       AssertEquals ("#18d", String.Empty, u.AbsolutePath);
+                       AssertEquals ("#18e", "news:", u.AbsoluteUri);
+#endif
+                       u = new Uri ("news:/foo");
+                       AssertEquals ("#19a", String.Empty, u.Host);
+#if NET_2_0
+                       AssertEquals ("#19b", UriHostNameType.Unknown, u.HostNameType);
+                       AssertEquals ("#19c", "news:/foo", u.ToString ());
+                       AssertEquals ("#19d", "/foo", u.AbsolutePath);
+                       AssertEquals ("#19e", "news:/foo", u.AbsoluteUri);
 #else
                        AssertEquals ("#19b", UriHostNameType.Basic, u.HostNameType);
-                       AssertEquals ("#19c", "news:foo", u.ToString ());\r
-                       AssertEquals ("#19d", "foo", u.AbsolutePath);\r
-                       AssertEquals ("#19e", "news:foo", u.AbsoluteUri);\r
-#endif\r
-                       u = new Uri ("news://foo");\r
-#if NET_2_0\r
-                       AssertEquals ("#20a", String.Empty, u.Host);\r
-                       AssertEquals ("#20b", UriHostNameType.Unknown, u.HostNameType);\r
-                       AssertEquals ("#20c", "news://foo", u.ToString ());\r
-                       AssertEquals ("#20d", "//foo", u.AbsolutePath);\r
-                       AssertEquals ("#20e", "news://foo", u.AbsoluteUri);\r
+                       AssertEquals ("#19c", "news:foo", u.ToString ());
+                       AssertEquals ("#19d", "foo", u.AbsolutePath);
+                       AssertEquals ("#19e", "news:foo", u.AbsoluteUri);
+#endif
+                       u = new Uri ("news://foo");
+#if NET_2_0
+                       AssertEquals ("#20a", String.Empty, u.Host);
+                       AssertEquals ("#20b", UriHostNameType.Unknown, u.HostNameType);
+                       AssertEquals ("#20c", "news://foo", u.ToString ());
+                       AssertEquals ("#20d", "//foo", u.AbsolutePath);
+                       AssertEquals ("#20e", "news://foo", u.AbsoluteUri);
 #else
-                       AssertEquals ("#20a", "foo", u.Host);\r
+                       AssertEquals ("#20a", "foo", u.Host);
                        AssertEquals ("#20b", UriHostNameType.Dns, u.HostNameType);
-                       AssertEquals ("#20c", "news://foo/", u.ToString ());\r
-                       AssertEquals ("#20d", "/", u.AbsolutePath);\r
-                       AssertEquals ("#20e", "news://foo/", u.AbsoluteUri);\r
-#endif\r
-                       u = new Uri ("news://foo/bar");\r
-#if NET_2_0\r
-                       AssertEquals ("#22a", String.Empty, u.Host);\r
-                       AssertEquals ("#22b", UriHostNameType.Unknown, u.HostNameType);\r
-                       AssertEquals ("#22c", "news://foo/bar", u.ToString ());\r
-                       AssertEquals ("#22d", "//foo/bar", u.AbsolutePath);\r
-                       AssertEquals ("#22e", "news://foo/bar", u.AbsoluteUri);\r
+                       AssertEquals ("#20c", "news://foo/", u.ToString ());
+                       AssertEquals ("#20d", "/", u.AbsolutePath);
+                       AssertEquals ("#20e", "news://foo/", u.AbsoluteUri);
+#endif
+                       u = new Uri ("news://foo/bar");
+#if NET_2_0
+                       AssertEquals ("#22a", String.Empty, u.Host);
+                       AssertEquals ("#22b", UriHostNameType.Unknown, u.HostNameType);
+                       AssertEquals ("#22c", "news://foo/bar", u.ToString ());
+                       AssertEquals ("#22d", "//foo/bar", u.AbsolutePath);
+                       AssertEquals ("#22e", "news://foo/bar", u.AbsoluteUri);
 #else
-                       AssertEquals ("#22a", "foo", u.Host);\r
-                       AssertEquals ("#22b", UriHostNameType.Dns, u.HostNameType);\r
-                       AssertEquals ("#22c", "news://foo/bar", u.ToString ());\r
-                       AssertEquals ("#22d", "/bar", u.AbsolutePath);\r
+                       AssertEquals ("#22a", "foo", u.Host);
+                       AssertEquals ("#22b", UriHostNameType.Dns, u.HostNameType);
+                       AssertEquals ("#22c", "news://foo/bar", u.ToString ());
+                       AssertEquals ("#22d", "/bar", u.AbsolutePath);
                        AssertEquals ("#22e", "news://foo/bar", u.AbsoluteUri);
-#endif\r
-               }\r
-\r
-               [Test]\r
+#endif
+               }
+
+               [Test]
 #if ONLY_1_1
                [Category ("NotDotNet")] // does (but shouldn't) fail under 1.x
-#endif\r
-               public void LeadingSlashes_FailOn1x ()\r
-               {\r
-                       // 1.x throws an UriFormatException because it can't decode the host name\r
-                       Uri u = new Uri ("mailto:");\r
-                       AssertEquals ("#10a", String.Empty, u.Host);\r
-                       AssertEquals ("#10b", UriHostNameType.Basic, u.HostNameType);\r
-                       AssertEquals ("#10c", "mailto:", u.ToString ());\r
-\r
-                       // 1.x throws an UriFormatException because it can't decode the host name\r
-                       u = new Uri ("mailto:/");\r
-                       AssertEquals ("#12a", String.Empty, u.Host);\r
-                       AssertEquals ("#12b", UriHostNameType.Basic, u.HostNameType);\r
-                       AssertEquals ("#12c", "mailto:/", u.ToString ());\r
-\r
-                       // 1.x throws an UriFormatException because it cannot detect the format\r
-                       u = new Uri ("mailto:///foo");\r
-                       AssertEquals ("#15a", String.Empty, u.Host);\r
-                       AssertEquals ("#15b", UriHostNameType.Basic, u.HostNameType);\r
-                       AssertEquals ("#15c", "mailto:///foo", u.ToString ());\r
-\r
-                       // 1.x throws an UriFormatException because it cannot detect the format\r
-                       u = new Uri ("news:///foo");\r
-                       AssertEquals ("#21a", String.Empty, u.Host);\r
-#if NET_2_0\r
-                       AssertEquals ("#21b", UriHostNameType.Unknown, u.HostNameType);\r
-#else\r
-                       AssertEquals ("#21b", UriHostNameType.Basic, u.HostNameType);\r
-#endif\r
-                       AssertEquals ("#21c", "news:///foo", u.ToString ());\r
-                       AssertEquals ("#21d", "///foo", u.AbsolutePath);\r
-                       AssertEquals ("#21e", "news:///foo", u.AbsoluteUri);\r
-               }\r
+#endif
+               public void LeadingSlashes_FailOn1x ()
+               {
+                       // 1.x throws an UriFormatException because it can't decode the host name
+                       Uri u = new Uri ("mailto:");
+                       AssertEquals ("#10a", String.Empty, u.Host);
+                       AssertEquals ("#10b", UriHostNameType.Basic, u.HostNameType);
+                       AssertEquals ("#10c", "mailto:", u.ToString ());
+
+                       // 1.x throws an UriFormatException because it can't decode the host name
+                       u = new Uri ("mailto:/");
+                       AssertEquals ("#12a", String.Empty, u.Host);
+                       AssertEquals ("#12b", UriHostNameType.Basic, u.HostNameType);
+                       AssertEquals ("#12c", "mailto:/", u.ToString ());
+
+                       // 1.x throws an UriFormatException because it cannot detect the format
+                       u = new Uri ("mailto:///foo");
+                       AssertEquals ("#15a", String.Empty, u.Host);
+                       AssertEquals ("#15b", UriHostNameType.Basic, u.HostNameType);
+                       AssertEquals ("#15c", "mailto:///foo", u.ToString ());
+
+                       // 1.x throws an UriFormatException because it cannot detect the format
+                       u = new Uri ("news:///foo");
+                       AssertEquals ("#21a", String.Empty, u.Host);
+#if NET_2_0
+                       AssertEquals ("#21b", UriHostNameType.Unknown, u.HostNameType);
+#else
+                       AssertEquals ("#21b", UriHostNameType.Basic, u.HostNameType);
+#endif
+                       AssertEquals ("#21c", "news:///foo", u.ToString ());
+                       AssertEquals ("#21d", "///foo", u.AbsolutePath);
+                       AssertEquals ("#21e", "news:///foo", u.AbsoluteUri);
+               }
 
                [Test]
                // some tests from bug 75144
                public void LeadingSlashes ()
                {
-                       Uri u = new Uri ("file://foo/bar");\r
-                       AssertEquals ("#5a", "foo", u.Host);\r
-                       AssertEquals ("#5b", UriHostNameType.Dns, u.HostNameType);\r
+                       Uri u = new Uri ("file://foo/bar");
+                       AssertEquals ("#5a", "foo", u.Host);
+                       AssertEquals ("#5b", UriHostNameType.Dns, u.HostNameType);
                        AssertEquals ("#5c", "file://foo/bar", u.ToString ());
                        AssertEquals ("#5d", true, u.IsUnc);
 
-                       u = new Uri ("file:////foo/bar");\r
-                       AssertEquals ("#7a", "foo", u.Host);\r
-                       AssertEquals ("#7b", UriHostNameType.Dns, u.HostNameType);\r
+                       u = new Uri ("file:////foo/bar");
+                       AssertEquals ("#7a", "foo", u.Host);
+                       AssertEquals ("#7b", UriHostNameType.Dns, u.HostNameType);
                        AssertEquals ("#7c", "file://foo/bar", u.ToString ());
                        AssertEquals ("#7d", true, u.IsUnc); 
 
                        AssertEquals ("#9", "file://foo/bar", new Uri ("file://///foo/bar").ToString());
-\r
-                       u = new Uri ("mailto:foo");\r
-                       AssertEquals ("#11a", "foo", u.Host);\r
-                       AssertEquals ("#11b", UriHostNameType.Dns, u.HostNameType);\r
-                       AssertEquals ("#11c", "mailto:foo", u.ToString ());\r
-\r
+
+                       u = new Uri ("mailto:foo");
+                       AssertEquals ("#11a", "foo", u.Host);
+                       AssertEquals ("#11b", UriHostNameType.Dns, u.HostNameType);
+                       AssertEquals ("#11c", "mailto:foo", u.ToString ());
+
                        u = new Uri ("news:");
                        AssertEquals ("#16a", String.Empty, u.Host);
-#if NET_2_0\r
+#if NET_2_0
                        AssertEquals ("#16b", UriHostNameType.Unknown, u.HostNameType);
 #else
                        AssertEquals ("#16b", UriHostNameType.Basic, u.HostNameType);
-#endif\r
-                       AssertEquals ("#16c", "news:", u.ToString ());\r
+#endif
+                       AssertEquals ("#16c", "news:", u.ToString ());
 
-                       u = new Uri ("news:foo");\r
-                       AssertEquals ("#17a", String.Empty, u.Host);\r
-#if NET_2_0\r
+                       u = new Uri ("news:foo");
+                       AssertEquals ("#17a", String.Empty, u.Host);
+#if NET_2_0
                        AssertEquals ("#17b", UriHostNameType.Unknown, u.HostNameType);
 #else
                        AssertEquals ("#17b", UriHostNameType.Basic, u.HostNameType);
-#endif\r
-                       AssertEquals ("#17c", "news:foo", u.ToString ());\r
-                       AssertEquals ("#17d", "foo", u.AbsolutePath);\r
-                       AssertEquals ("#17e", "news:foo", u.AbsoluteUri);\r
+#endif
+                       AssertEquals ("#17c", "news:foo", u.ToString ());
+                       AssertEquals ("#17d", "foo", u.AbsolutePath);
+                       AssertEquals ("#17e", "news:foo", u.AbsoluteUri);
                }
 
                [Test]
@@ -538,7 +538,7 @@ namespace MonoTests.System
                public void InvalidFile3 ()
                {
                        new Uri ("file:/foo");
-               }       
+               }
 
                [Test]
                [ExpectedException (typeof (UriFormatException))]
@@ -622,66 +622,66 @@ namespace MonoTests.System
                        // Hmm, they should be regarded just as a host name, since all URIs are base on absolute path.
                        Uri uri = new Uri("file://one_file.txt");
 #if NET_2_0
-                       AssertEquals("#6a", "file://one_file.txt/", uri.ToString());\r
-                       AssertEquals ("#6e", "/", uri.AbsolutePath);\r
-                       AssertEquals ("#6f", "/", uri.PathAndQuery);\r
-                       AssertEquals ("#6g", "file://one_file.txt/", uri.GetLeftPart (UriPartial.Path));\r
+                       AssertEquals("#6a", "file://one_file.txt/", uri.ToString());
+                       AssertEquals ("#6e", "/", uri.AbsolutePath);
+                       AssertEquals ("#6f", "/", uri.PathAndQuery);
+                       AssertEquals ("#6g", "file://one_file.txt/", uri.GetLeftPart (UriPartial.Path));
 #else
                        AssertEquals("#6a", "file://one_file.txt", uri.ToString());
                        AssertEquals("#6e", "", uri.AbsolutePath);
-                       AssertEquals ("#6f", "", uri.PathAndQuery);\r
-                       AssertEquals ("#6g", "file://one_file.txt", uri.GetLeftPart (UriPartial.Path));\r
-#endif\r
+                       AssertEquals ("#6f", "", uri.PathAndQuery);
+                       AssertEquals ("#6g", "file://one_file.txt", uri.GetLeftPart (UriPartial.Path));
+#endif
                        if (isWin32)
                                AssertEquals("#6b", "\\\\one_file.txt", uri.LocalPath);
                        else
                                AssertEquals("#6b", "/", uri.LocalPath);
                        AssertEquals("#6c", "file", uri.Scheme);
-                       AssertEquals("#6d", "one_file.txt", uri.Host);\r
-\r
-                       // same tests - but original Uri is now ending with a '/'\r
-\r
-                       uri = new Uri ("file://one_file.txt/");\r
-                       AssertEquals ("#7a", "file://one_file.txt/", uri.ToString ());\r
-                       AssertEquals ("#7e", "/", uri.AbsolutePath);\r
-                       AssertEquals ("#7f", "/", uri.PathAndQuery);\r
-                       AssertEquals ("#7g", "file://one_file.txt/", uri.GetLeftPart (UriPartial.Path));\r
+                       AssertEquals("#6d", "one_file.txt", uri.Host);
+
+                       // same tests - but original Uri is now ending with a '/'
+
+                       uri = new Uri ("file://one_file.txt/");
+                       AssertEquals ("#7a", "file://one_file.txt/", uri.ToString ());
+                       AssertEquals ("#7e", "/", uri.AbsolutePath);
+                       AssertEquals ("#7f", "/", uri.PathAndQuery);
+                       AssertEquals ("#7g", "file://one_file.txt/", uri.GetLeftPart (UriPartial.Path));
 #if !TARGET_JVM
-                       if (isWin32)\r
-                               AssertEquals ("#7b", "\\\\one_file.txt\\", uri.LocalPath);\r
-                       else\r
-                               AssertEquals ("#7b", "/", uri.LocalPath);\r
+                       if (isWin32)
+                               AssertEquals ("#7b", "\\\\one_file.txt\\", uri.LocalPath);
+                       else
+                               AssertEquals ("#7b", "/", uri.LocalPath);
 #endif
-                       AssertEquals ("#7c", "file", uri.Scheme);\r
-                       AssertEquals ("#7d", "one_file.txt", uri.Host);\r
+                       AssertEquals ("#7c", "file", uri.Scheme);
+                       AssertEquals ("#7d", "one_file.txt", uri.Host);
                }
 
                [Test]
                public void LocalPath_Escape ()
                {
                        // escape
-                       Uri uri = new Uri ("file:///tmp/a%20a");\r
-                       if (isWin32) {\r
-#if NET_2_0\r
-                               Assert ("#7a:" + uri.LocalPath, uri.LocalPath.EndsWith ("/tmp/a a"));\r
-#else\r
-                               // actually MS.NET treats /// as \\ thus it fails here.\r
-                               Assert ("#7a:" + uri.LocalPath, uri.LocalPath.EndsWith ("\\tmp\\a a"));\r
-#endif\r
-                       } else\r
+                       Uri uri = new Uri ("file:///tmp/a%20a");
+                       if (isWin32) {
+#if NET_2_0
+                               Assert ("#7a:" + uri.LocalPath, uri.LocalPath.EndsWith ("/tmp/a a"));
+#else
+                               // actually MS.NET treats /// as \\ thus it fails here.
+                               Assert ("#7a:" + uri.LocalPath, uri.LocalPath.EndsWith ("\\tmp\\a a"));
+#endif
+                       } else
                                AssertEquals ("#7b", "/tmp/a a", uri.LocalPath);
 
                        uri = new Uri ("file:///tmp/foo%25bar");
                        if (isWin32) {
-#if NET_2_0\r
-                               Assert ("#8a:" + uri.LocalPath, uri.LocalPath.EndsWith ("/tmp/foo%bar"));\r
-                               Assert ("#8c:" + uri.ToString (), uri.ToString ().EndsWith ("//tmp/foo%25bar"));\r
+#if NET_2_0
+                               Assert ("#8a:" + uri.LocalPath, uri.LocalPath.EndsWith ("/tmp/foo%bar"));
+                               Assert ("#8c:" + uri.ToString (), uri.ToString ().EndsWith ("//tmp/foo%25bar"));
 #else
                                // actually MS.NET treats /// as \\ thus it fails here.
                                Assert ("#8a:" + uri.LocalPath, uri.LocalPath.EndsWith ("\\tmp\\foo%bar"));
-                               // ditto, file://tmp/foo%25bar (bug in 1.x)\r
-                               Assert ("#8c:" + uri.ToString (), uri.ToString ().EndsWith ("//tmp/foo%bar"));\r
-#endif\r
+                               // ditto, file://tmp/foo%25bar (bug in 1.x)
+                               Assert ("#8c:" + uri.ToString (), uri.ToString ().EndsWith ("//tmp/foo%bar"));
+#endif
                        } else {
                                AssertEquals ("#8b", "/tmp/foo%bar", uri.LocalPath);
                                AssertEquals ("#8d", "file:///tmp/foo%25bar", uri.ToString ());
@@ -689,14 +689,14 @@ namespace MonoTests.System
                        // bug #76643
                        uri = new Uri ("file:///foo%25bar");
                        if (isWin32) {
-#if NET_2_0\r
-                               Assert ("#9a:" + uri.LocalPath, uri.LocalPath.EndsWith ("/foo%bar"));\r
+#if NET_2_0
+                               Assert ("#9a:" + uri.LocalPath, uri.LocalPath.EndsWith ("/foo%bar"));
 #else
                                // actually MS.NET treats /// as \\ thus it fails here.
                                Assert ("#9a:" + uri.LocalPath, uri.LocalPath.EndsWith ("\\foo%25bar"));
-#endif\r
-                               // ditto, file://tmp/foo%25bar (bug in 1.x)\r
-                               Assert ("#9c:" + uri.ToString (), uri.ToString ().EndsWith ("//foo%25bar"));\r
+#endif
+                               // ditto, file://tmp/foo%25bar (bug in 1.x)
+                               Assert ("#9c:" + uri.ToString (), uri.ToString ().EndsWith ("//foo%25bar"));
                        } else {
                                AssertEquals ("#9b", "/foo%bar", uri.LocalPath);
                                AssertEquals ("#9d", "file:///foo%25bar", uri.ToString ());
@@ -930,7 +930,7 @@ namespace MonoTests.System
                }
 
                [Test]
-               public void FragmentEscape ()
+               public void Fragment_Escape ()
                {
                        Uri u = new Uri("http://localhost/index.asp#main#start", false);
                        AssertEquals ("#1", u.Fragment, "#main%23start");
@@ -947,7 +947,27 @@ namespace MonoTests.System
                        n = new Uri (b, "blah#main#start", true);
                        AssertEquals ("#4", n.Fragment, "#main#start");
                }
-                       
+
+#if NET_2_0
+               [Test]
+               public void Fragment_RelativeUri ()
+               {
+                       Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+                       Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+                       Uri relativeUri = uri1.MakeRelativeUri (uri2);
+
+                       try {
+                               string fragment = relativeUri.Fragment;
+                               Fail ("#1: " + fragment);
+                       } catch (InvalidOperationException ex) {
+                               // This operation is not supported for a relative URI
+                               AssertEquals ("#2", typeof (InvalidOperationException), ex.GetType ());
+                               AssertNull ("#3", ex.InnerException);
+                               AssertNotNull ("#4", ex.Message);
+                       }
+               }
+#endif
+
                [Test]
                [ExpectedException(typeof(UriFormatException))]
                public void IncompleteSchemeDelimiter ()
@@ -1011,11 +1031,11 @@ namespace MonoTests.System
                        AssertEquals ("#41", UriHostNameType.Unknown, Uri.CheckHostName ("::abce:"));
                        AssertEquals ("#42", UriHostNameType.Unknown, Uri.CheckHostName ("::abcg"));
                        AssertEquals ("#43", UriHostNameType.Unknown, Uri.CheckHostName (":::"));
-                       AssertEquals ("#44", UriHostNameType.Unknown, Uri.CheckHostName (":"));\r
-\r
-                       AssertEquals ("#45", UriHostNameType.Unknown, Uri.CheckHostName ("*"));\r
-                       AssertEquals ("#46", UriHostNameType.Unknown, Uri.CheckHostName ("*.go-mono.com"));\r
-                       AssertEquals ("#47", UriHostNameType.Unknown, Uri.CheckHostName ("www*.go-mono.com"));\r
+                       AssertEquals ("#44", UriHostNameType.Unknown, Uri.CheckHostName (":"));
+
+                       AssertEquals ("#45", UriHostNameType.Unknown, Uri.CheckHostName ("*"));
+                       AssertEquals ("#46", UriHostNameType.Unknown, Uri.CheckHostName ("*.go-mono.com"));
+                       AssertEquals ("#47", UriHostNameType.Unknown, Uri.CheckHostName ("www*.go-mono.com"));
                }
                
                [Test]
@@ -1046,34 +1066,34 @@ namespace MonoTests.System
                        uri = new Uri("http://[::ff00:7f11:2233]:8080");
                        AssertEquals ("#12", false, uri.IsLoopback);
                        uri = new Uri("http://[1:0:0:0::1]:8080");
-                       AssertEquals ("#13", false, uri.IsLoopback);\r
-               }\r
-\r
-               [Test]\r
-               public void IsLoopback_File ()\r
-               {\r
+                       AssertEquals ("#13", false, uri.IsLoopback);
+               }
+
+               [Test]
+               public void IsLoopback_File ()
+               {
                        Uri uri = new Uri ("file:///index.html");
-#if NET_2_0\r
+#if NET_2_0
                        Assert ("file", uri.IsLoopback);
 #else
                        Assert ("file", !uri.IsLoopback);
-#endif\r
-               }\r
-\r
-               [Test]\r
-               public void IsLoopback_Relative_Http ()\r
-               {\r
-                       string relative = "http:8080/bar/Hello World.htm";\r
-                       Uri uri = new Uri (new Uri ("http://www.contoso.com"), relative, false);\r
-                       Assert ("http", !uri.IsLoopback);\r
-               }\r
-\r
-               [Test]\r
-               public void IsLoopback_Relative_Unknown ()\r
-               {\r
-                       string relative = "foo:8080/bar/Hello World.htm";\r
-                       Uri uri = new Uri (new Uri ("http://www.contoso.com"), relative, false);\r
-                       Assert ("foo", !uri.IsLoopback);\r
+#endif
+               }
+
+               [Test]
+               public void IsLoopback_Relative_Http ()
+               {
+                       string relative = "http:8080/bar/Hello World.htm";
+                       Uri uri = new Uri (new Uri ("http://www.contoso.com"), relative, false);
+                       Assert ("http", !uri.IsLoopback);
+               }
+
+               [Test]
+               public void IsLoopback_Relative_Unknown ()
+               {
+                       string relative = "foo:8080/bar/Hello World.htm";
+                       Uri uri = new Uri (new Uri ("http://www.contoso.com"), relative, false);
+                       Assert ("foo", !uri.IsLoopback);
                }
 
                [Test]
@@ -1115,9 +1135,9 @@ namespace MonoTests.System
 
                        a = new Uri ("mailto:user:pwd@go-mono.com?subject=uri");
                        b = new Uri ("MAILTO:USER:PWD@GO-MONO.COM?SUBJECT=URI");
-#if NET_2_0\r
-                       Assert ("#2", a != b);\r
-                       AssertEquals ("#2a", "mailto:user:pwd@go-mono.com?subject=uri", a.ToString ());\r
+#if NET_2_0
+                       Assert ("#2", a != b);
+                       AssertEquals ("#2a", "mailto:user:pwd@go-mono.com?subject=uri", a.ToString ());
                        AssertEquals ("#2b", "mailto:USER:PWD@go-mono.com?SUBJECT=URI", b.ToString ());
 #else
                        AssertEquals ("#2", a, b);
@@ -1126,26 +1146,26 @@ namespace MonoTests.System
                        b = new Uri ("http://www.go-mono.com/PORTS/");
 
                        Assert ("#3", !a.Equals (b));
-               }\r
-\r
-               [Test]\r
-               public void CaseSensitivity ()\r
-               {\r
-                       Uri mailto = new Uri ("MAILTO:USER:PWD@GO-MONO.COM?SUBJECT=URI");\r
-                       AssertEquals ("#1", "mailto", mailto.Scheme);\r
-                       AssertEquals ("#2", "go-mono.com", mailto.Host);\r
-                       AssertEquals ("#3", "mailto:USER:PWD@go-mono.com?SUBJECT=URI", mailto.ToString ());\r
-\r
-                       Uri http = new Uri ("HTTP://GO-MONO.COM/INDEX.HTML");\r
-                       AssertEquals ("#4", "http", http.Scheme);\r
-                       AssertEquals ("#5", "go-mono.com", http.Host);\r
-                       AssertEquals ("#6", "http://go-mono.com/INDEX.HTML", http.ToString ());\r
-\r
-                       // IPv6 Address\r
-                       Uri ftp = new Uri ("FTP://[::ffFF:169.32.14.5]/");\r
-                       AssertEquals ("#7", "ftp", ftp.Scheme);\r
-                       AssertEquals ("#8", "[0000:0000:0000:0000:0000:FFFF:A920:0E05]", ftp.Host);\r
-                       AssertEquals ("#9", "ftp://[0000:0000:0000:0000:0000:FFFF:A920:0E05]/", ftp.ToString ());\r
+               }
+
+               [Test]
+               public void CaseSensitivity ()
+               {
+                       Uri mailto = new Uri ("MAILTO:USER:PWD@GO-MONO.COM?SUBJECT=URI");
+                       AssertEquals ("#1", "mailto", mailto.Scheme);
+                       AssertEquals ("#2", "go-mono.com", mailto.Host);
+                       AssertEquals ("#3", "mailto:USER:PWD@go-mono.com?SUBJECT=URI", mailto.ToString ());
+
+                       Uri http = new Uri ("HTTP://GO-MONO.COM/INDEX.HTML");
+                       AssertEquals ("#4", "http", http.Scheme);
+                       AssertEquals ("#5", "go-mono.com", http.Host);
+                       AssertEquals ("#6", "http://go-mono.com/INDEX.HTML", http.ToString ());
+
+                       // IPv6 Address
+                       Uri ftp = new Uri ("FTP://[::ffFF:169.32.14.5]/");
+                       AssertEquals ("#7", "ftp", ftp.Scheme);
+                       AssertEquals ("#8", "[0000:0000:0000:0000:0000:FFFF:A920:0E05]", ftp.Host);
+                       AssertEquals ("#9", "ftp://[0000:0000:0000:0000:0000:FFFF:A920:0E05]/", ftp.ToString ());
                }
 
                [Test]
@@ -1243,7 +1263,7 @@ namespace MonoTests.System
                        AssertEquals ("#2", "../../index.htm", uri2.MakeRelative (uri1));
                        
                        AssertEquals ("#3", "../../bar/foo/index.htm", uri2.MakeRelative (uri3));
-                       AssertEquals ("#4", "../../foo/bar/index.htm", uri3.MakeRelative (uri2));                       
+                       AssertEquals ("#4", "../../foo/bar/index.htm", uri3.MakeRelative (uri2));
 
                        AssertEquals ("#5", "../foo2/index.htm", uri3.MakeRelative (uri4));
                        AssertEquals ("#6", "../foo/index.htm", uri4.MakeRelative (uri3));
@@ -1308,7 +1328,7 @@ namespace MonoTests.System
 
                [Test]
                public void ToStringTest()
-               {                       
+               {
                        Uri uri = new Uri ("dummy://xxx");
                        AssertEquals ("#1", "dummy://xxx/", uri.ToString ());
                }
@@ -1325,51 +1345,51 @@ namespace MonoTests.System
                        AssertEquals ("#07", false, Uri.CheckSchemeName ("http6,"));
                        AssertEquals ("#08", true, Uri.CheckSchemeName ("http6."));
                        AssertEquals ("#09", false, Uri.CheckSchemeName ("+http"));
-                       AssertEquals ("#10", true, Uri.CheckSchemeName ("htt+p6"));\r
-                       // 0x00E1 -> &atilde;\r
+                       AssertEquals ("#10", true, Uri.CheckSchemeName ("htt+p6"));
+                       // 0x00E1 -> &atilde;
 #if NET_2_0
                        Assert ("#11", !Uri.CheckSchemeName ("htt\u00E1+p6"));
 #else
                        Assert ("#11", Uri.CheckSchemeName ("htt\u00E1+p6"));
-#endif\r
-               }\r
-\r
-               [Test]\r
-               public void CheckSchemeName_FirstChar ()\r
-               {\r
-                       for (int i = 0; i < 256; i++) {\r
-                               string s = String.Format ("#{0}", i);\r
-                               char c = (char) i;\r
-                               bool b = Uri.CheckSchemeName (c.ToString ());\r
-#if NET_2_0\r
-                               bool valid = (((i >= 0x41) && (i <= 0x5A)) || ((i >= 0x61) && (i <= 0x7A)));\r
-                               AssertEquals (s, valid, b);\r
-#else\r
-                               AssertEquals (s, Char.IsLetter (c), b);\r
-#endif\r
-                       }\r
-               }\r
-\r
-               [Test]\r
-               public void CheckSchemeName_AnyOtherChar ()\r
-               {\r
-                       for (int i = 0; i < 256; i++) {\r
-                               string s = String.Format ("#{0}", i);\r
-                               char c = (char) i;\r
-                               string scheme = String.Format ("a+b-c.d{0}", c);\r
-                               bool b = Uri.CheckSchemeName (scheme);\r
-                               bool common = Char.IsDigit (c) || (c == '+') || (c == '-') || (c == '.');\r
-#if NET_2_0\r
-                               bool valid = (common || ((i >= 0x41) && (i <= 0x5A)) || ((i >= 0x61) && (i <= 0x7A)));\r
-                               AssertEquals (s, valid, b);\r
-#else\r
-                               AssertEquals (s, (Char.IsLetter (c) || common), b);\r
-#endif\r
-                       }\r
-               }\r
-\r
-               [Test]\r
-               [ExpectedException (typeof (UriFormatException))]\r
+#endif
+               }
+
+               [Test]
+               public void CheckSchemeName_FirstChar ()
+               {
+                       for (int i = 0; i < 256; i++) {
+                               string s = String.Format ("#{0}", i);
+                               char c = (char) i;
+                               bool b = Uri.CheckSchemeName (c.ToString ());
+#if NET_2_0
+                               bool valid = (((i >= 0x41) && (i <= 0x5A)) || ((i >= 0x61) && (i <= 0x7A)));
+                               AssertEquals (s, valid, b);
+#else
+                               AssertEquals (s, Char.IsLetter (c), b);
+#endif
+                       }
+               }
+
+               [Test]
+               public void CheckSchemeName_AnyOtherChar ()
+               {
+                       for (int i = 0; i < 256; i++) {
+                               string s = String.Format ("#{0}", i);
+                               char c = (char) i;
+                               string scheme = String.Format ("a+b-c.d{0}", c);
+                               bool b = Uri.CheckSchemeName (scheme);
+                               bool common = Char.IsDigit (c) || (c == '+') || (c == '-') || (c == '.');
+#if NET_2_0
+                               bool valid = (common || ((i >= 0x41) && (i <= 0x5A)) || ((i >= 0x61) && (i <= 0x7A)));
+                               AssertEquals (s, valid, b);
+#else
+                               AssertEquals (s, (Char.IsLetter (c) || common), b);
+#endif
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (UriFormatException))]
                public void NoHostname ()
                {
                        Uri uri = new Uri ("http://");
@@ -1450,12 +1470,12 @@ namespace MonoTests.System
                        string [] segments = uri.Segments;
                        AssertEquals ("#01", 3, segments.Length);
 #if NET_2_0
-                       AssertEquals ("#02", "/", segments [0]);\r
-                       AssertEquals ("#03", "c:/", segments[1]);\r
+                       AssertEquals ("#02", "/", segments [0]);
+                       AssertEquals ("#03", "c:/", segments[1]);
 #else
                        AssertEquals ("#02", "c:", segments [0]);
                        AssertEquals ("#03", "/", segments [1]);
-#endif\r
+#endif
                        AssertEquals ("#04", "hello", segments [2]);
                }
 
@@ -1587,8 +1607,7 @@ namespace MonoTests.System
                                sb.Append ((char) i);
                        
                        AssertEquals ("%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22#$%25&'()*+,-./0123456789:;%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F",
-                                     Uri.EscapeUriString (sb.ToString ()));
-                                     
+                               Uri.EscapeUriString (sb.ToString ()));
                        AssertEquals ("%C3%A1", Uri.EscapeDataString ("รก"));
                }
 #endif
@@ -1642,7 +1661,7 @@ namespace MonoTests.System
                        Console.WriteLine ("IsLoopback: " + uri.IsLoopback);
                        Console.WriteLine ("IsUnc: " + uri.IsUnc);
                        Console.WriteLine ("LocalPath: " + uri.LocalPath);
-                       Console.WriteLine ("PathAndQuery: " + uri.PathAndQuery);
+                       Console.WriteLine ("PathAndQuery        : " + uri.PathAndQuery);
                        Console.WriteLine ("Port: " + uri.Port);
                        Console.WriteLine ("Query: " + uri.Query);
                        Console.WriteLine ("Scheme: " + uri.Scheme);
@@ -1655,9 +1674,8 @@ namespace MonoTests.System
                                Console.WriteLine ("\tNo Segments");
                        else 
                                for (int i = 0; i < segments.Length; i++) 
-                                       Console.WriteLine ("\t" + segments[i]);                                 
+                                       Console.WriteLine ("\t" + segments[i]);
                        Console.WriteLine ("");
                }
        }
 }
-
index 6738006fbc9b7eac0848a04478d820caf2932d54..c6956a811bffb578a6605a48f385167595a7b929 100644 (file)
@@ -1,9 +1,9 @@
 //\r
 // UriTest2.cs - More NUnit Test Cases for System.Uri\r
-//
+//\r
 \r
 using System;\r
-using System.IO;
+using System.IO;\r
 using System.Reflection;\r
 using System.Text;\r
 using NUnit.Framework;\r
@@ -83,8 +83,8 @@ namespace MonoTests.System
                }\r
                \r
                private void FromResource (string res, Uri baseUri)\r
-               {
-                       Assembly a = Assembly.GetExecutingAssembly ();
+               {\r
+                       Assembly a = Assembly.GetExecutingAssembly ();\r
                        Stream s = a.GetManifestResourceStream (res);\r
                        StreamReader sr = new StreamReader (s, Encoding.UTF8);\r
                        while (sr.Peek () > 0) {\r
@@ -143,14 +143,14 @@ TextWriter sw = Console.Out;
                                }\r
                        }\r
                }\r
-
-               [Test]
-               public void MoreUnescape () // bug 733316
-               {
-                       int index = 0;
+\r
+               [Test]\r
+               public void MoreUnescape () // bug 733316\r
+               {\r
+                       int index = 0;\r
                        char unesc = Uri.HexUnescape ("%F6", ref index);\r
                        Assert.AreEqual (3, index, "#01");\r
-                       Assert.AreEqual (0xf6, unesc, "#02");
+                       Assert.AreEqual (0xf6, unesc, "#02");\r
                }\r
 \r
                [Test]\r
@@ -177,7 +177,7 @@ TextWriter sw = Console.Out;
                {\r
                        new Uri ("http://w*w*w.go-mono.com");\r
                }\r
-
+\r
                [Test]\r
 #if ONLY_1_1\r
                [Category ("NotDotNet")] // 1.x throws an UriFormatException\r
@@ -190,7 +190,7 @@ TextWriter sw = Console.Out;
                        Assert.AreEqual (String.Empty, u.Authority, "Authority");\r
                        Assert.AreEqual (String.Empty, u.Fragment, "Fragment");\r
                        Assert.AreEqual (String.Empty, u.Host, "Host");\r
-                       // FIXME (2.0) - Normally this is never Basic without an Host name :(
+                       // FIXME (2.0) - Normally this is never Basic without an Host name :(\r
                        // Assert.AreEqual (UriHostNameType.Basic, u.HostNameType, "HostNameType");\r
                        Assert.IsTrue (u.IsDefaultPort, "IsDefaultPort");\r
                        Assert.IsFalse (u.IsFile, "IsFile");\r
@@ -214,8 +214,8 @@ TextWriter sw = Console.Out;
                        Assert.AreEqual ("foo:///bar", u.AbsoluteUri, "AbsoluteUri");\r
                        Assert.AreEqual (String.Empty, u.Authority, "Authority");\r
                        Assert.AreEqual (String.Empty, u.Fragment, "Fragment");\r
-                       Assert.AreEqual (String.Empty, u.Host, "Host");
-                       // FIXME (2.0) - Normally this is never Basic without an Host name :(
+                       Assert.AreEqual (String.Empty, u.Host, "Host");\r
+                       // FIXME (2.0) - Normally this is never Basic without an Host name :(\r
                        // Assert.AreEqual (UriHostNameType.Basic, u.HostNameType, "HostNameType");\r
                        Assert.IsTrue (u.IsDefaultPort, "IsDefaultPort");\r
                        Assert.IsFalse (u.IsFile, "IsFile");\r
index 7cd2289f447e433d4b2a695aba34a7a8237f43dd..6c4362608ef27152219f0054188cdb1baf704c4e 100644 (file)
@@ -32,14 +32,32 @@ using NUnit.Framework;
 
 using System;
 
-namespace MonoTests.System {
-
+namespace MonoTests.System
+{
        [TestFixture]
-       public class UriTest3 {
-
+       public class UriTest3
+       {
                private const string absolute = "http://www.mono-project.com/CAS";
                private const string relative = "server.com/directory/";
 
+               [Test]
+               public void AbsoluteUri_RelativeUri ()
+               {
+                       Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+                       Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+                       Uri relativeUri = uri1.MakeRelativeUri (uri2);
+
+                       try {
+                               string result = relativeUri.AbsoluteUri;
+                               Assert.Fail ("#1: " + result);
+                       } catch (InvalidOperationException ex) {
+                               // This operation is not supported for a relative URI
+                               Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                       }
+               }
+
                [Test]
                public void Absolute_UriKind_Absolute ()
                {
@@ -273,6 +291,84 @@ namespace MonoTests.System {
                        http.IsBaseOf (null);
                }
 
+               [Test] // bug #328693
+               [Category ("NotWorking")]
+               public void MakeRelativeUri ()
+               {
+                       Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+                       Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+                       Uri uri3 = new Uri ("http://www.contoso.com/bar/foo/index.htm?y=1");
+                       Uri uri4 = new Uri ("http://www.contoso.com/bar/foo2/index.htm?x=0");
+                       Uri uri5 = new Uri ("https://www.contoso.com/bar/foo/index.htm?y=1");
+                       Uri uri6 = new Uri ("http://www.contoso2.com/bar/foo/index.htm?x=0");
+                       Uri uri7 = new Uri ("http://www.contoso2.com/bar/foo/foobar.htm?z=0&y=5");
+                       Uri uri8 = new Uri ("http://www.xxx.com/bar/foo/foobar.htm?z=0&y=5" + (char) 0xa9);
+                       Uri uri10 = new Uri ("mailto:xxx@xxx.com");
+                       Uri uri11 = new Uri ("mailto:xxx@xxx.com?subject=hola");
+                       Uri uri12 = new Uri ("mailto:xxx@mail.xxx.com?subject=hola");
+                       Uri uri13 = new Uri ("mailto:xxx@xxx.com/foo/bar");
+
+                       AssertRelativeUri ("foo/bar/index.htm#fragment", uri1, uri2, "#A");
+                       AssertRelativeUri ("../../index.htm?x=2", uri2, uri1, "#B");
+                       AssertRelativeUri ("../../bar/foo/index.htm?y=1", uri2, uri3, "#C");
+                       AssertRelativeUri ("../../foo/bar/index.htm#fragment", uri3, uri2, "#D");
+                       AssertRelativeUri ("../foo2/index.htm?x=0", uri3, uri4, "#E");
+                       AssertRelativeUri ("../foo/index.htm?y=1", uri4, uri3, "#F");
+                       AssertRelativeUri ("?x=0", uri6, uri6, "#G");
+                       AssertRelativeUri ("foobar.htm?z=0&y=5", uri6, uri7, "#H");
+                       AssertRelativeUri ("?subject=hola", uri10, uri11, "#I");
+                       AssertRelativeUri ("/foo/bar", uri10, uri13, "#J");
+
+                       Uri relativeUri = uri1.MakeRelativeUri (uri8);
+                       Assert.IsTrue (relativeUri.IsAbsoluteUri, "#K1");
+                       Assert.AreEqual (uri8.ToString (), relativeUri.ToString (), "#K2");
+                       Assert.AreEqual (uri8.OriginalString, relativeUri.OriginalString, "#K3");
+
+                       relativeUri = uri10.MakeRelativeUri (uri12);
+                       Assert.IsTrue (relativeUri.IsAbsoluteUri, "#L1");
+                       Assert.AreEqual (uri12.ToString (), relativeUri.ToString (), "#L2");
+                       Assert.AreEqual (uri12.OriginalString, relativeUri.OriginalString, "#L3");
+
+                       relativeUri = uri4.MakeRelativeUri (uri6);
+                       Assert.IsTrue (relativeUri.IsAbsoluteUri, "#M1");
+                       Assert.AreEqual (uri6.ToString (), relativeUri.ToString (), "#M2");
+                       Assert.AreEqual (uri6.OriginalString, relativeUri.OriginalString, "#M3");
+
+                       relativeUri = uri4.MakeRelativeUri (uri5);
+                       Assert.IsTrue (relativeUri.IsAbsoluteUri, "#N1");
+                       Assert.AreEqual (uri5.ToString (), relativeUri.ToString (), "#N2");
+                       Assert.AreEqual (uri5.OriginalString, relativeUri.OriginalString, "#N3");
+               }
+
+               [Test]
+               [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299942
+               public void MakeRelativeUri_Uri_Null_Mono ()
+               {
+                       Uri uri = new Uri ("http://test.com");
+                       try {
+                               uri.MakeRelativeUri ((Uri) null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsNotNull (ex.ParamName, "#5");
+                               Assert.AreEqual ("uri", ex.ParamName, "#6");
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299942
+               public void MakeRelativeUri_Uri_Null_MS ()
+               {
+                       Uri uri = new Uri ("http://test.com");
+                       try {
+                               uri.MakeRelativeUri ((Uri) null);
+                               Assert.Fail ("#1");
+                       } catch (NullReferenceException) {
+                       }
+               }
+
                [Test]
                // LAMESPEC: see bug #78374.
                public void OriginalStringRelative ()
@@ -297,6 +393,60 @@ namespace MonoTests.System {
                        // Assert.AreEqual ("http://www.mono-project.com:303/foo?query", e.OriginalString, "#4");
                }
 
+               [Test]
+               public void PathAndQuery_RelativeUri ()
+               {
+                       Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+                       Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+                       Uri relativeUri = uri1.MakeRelativeUri (uri2);
+
+                       try {
+                               string result = relativeUri.PathAndQuery;
+                               Assert.Fail ("#1: " + result);
+                       } catch (InvalidOperationException ex) {
+                               // This operation is not supported for a relative URI
+                               Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                       }
+               }
+
+               [Test]
+               public void Query_RelativeUri ()
+               {
+                       Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+                       Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+                       Uri relativeUri = uri1.MakeRelativeUri (uri2);
+
+                       try {
+                               string result = relativeUri.Query;
+                               Assert.Fail ("#1: " + result);
+                       } catch (InvalidOperationException ex) {
+                               // This operation is not supported for a relative URI
+                               Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                       }
+               }
+
+               [Test]
+               public void Scheme_RelativeUri ()
+               {
+                       Uri uri1 = new Uri ("http://www.contoso.com/index.htm?x=2");
+                       Uri uri2 = new Uri ("http://www.contoso.com/foo/bar/index.htm#fragment");
+                       Uri relativeUri = uri1.MakeRelativeUri (uri2);
+
+                       try {
+                               string result = relativeUri.Scheme;
+                               Assert.Fail ("#1: " + result);
+                       } catch (InvalidOperationException ex) {
+                               // This operation is not supported for a relative URI
+                               Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                       }
+               }
+
                [Test]
                public void UnescapeDataString ()
                {
@@ -304,6 +454,14 @@ namespace MonoTests.System {
                        Assert.AreEqual ("/new folder/", Uri.UnescapeDataString ("/new%20%66older/"));
                        Assert.AreEqual ("/new+folder/", Uri.UnescapeDataString ("/new+folder/"));
                }
+
+               void AssertRelativeUri (string expected, Uri uri1, Uri uri2, string msg)
+               {
+                       Uri relativeUri = uri1.MakeRelativeUri (uri2);
+                       Assert.IsFalse (relativeUri.IsAbsoluteUri, msg + "1");
+                       Assert.AreEqual (expected, relativeUri.ToString (), msg + "2");
+                       Assert.AreEqual (expected, relativeUri.OriginalString, msg + "3");
+               }
        }
 }