Author: spouliot
Date: 2005-11-25 10:39:15 -0500 (Fri, 25 Nov 2005)
New Revision: 53479

Modified:
   trunk/mcs/class/System/Test/System/ChangeLog
   trunk/mcs/class/System/Test/System/UriBuilderCas.cs
   trunk/mcs/class/System/Test/System/UriBuilderTest.cs
   trunk/mcs/class/System/Test/System/UriParserTest.cs
   trunk/mcs/class/System/Test/System/UriTest3.cs
Log:
2005-11-25  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * UriBuilderCas.cs: Fixed line endings.
        * UriBuilderTest.cs: Fixed line endings and added some comments about 
        some NotWorking stuff.
        * UriParserTest.cs: Added test cases for default parser.
        * UriTest3.cs: Added more test cases for new 2.0 features.



Modified: trunk/mcs/class/System/Test/System/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System/ChangeLog        2005-11-25 15:32:19 UTC 
(rev 53478)
+++ trunk/mcs/class/System/Test/System/ChangeLog        2005-11-25 15:39:15 UTC 
(rev 53479)
@@ -1,3 +1,11 @@
+2005-11-25  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * UriBuilderCas.cs: Fixed line endings.
+       * UriBuilderTest.cs: Fixed line endings and added some comments about 
+       some NotWorking stuff.
+       * UriParserTest.cs: Added test cases for default parser.
+       * UriTest3.cs: Added more test cases for new 2.0 features.
+
 2005-11-15  Sebastien Pouliot  <[EMAIL PROTECTED]> 
  
        * UriTest2.cs: Added some new test cases for old (and now fixed) Uri

Modified: trunk/mcs/class/System/Test/System/UriBuilderCas.cs
===================================================================
--- trunk/mcs/class/System/Test/System/UriBuilderCas.cs 2005-11-25 15:32:19 UTC 
(rev 53478)
+++ trunk/mcs/class/System/Test/System/UriBuilderCas.cs 2005-11-25 15:39:15 UTC 
(rev 53479)
@@ -1,4 +1,4 @@
-//
+//
 // UriBuilderCas.cs - CAS unit tests for System
 //
 // Author:
@@ -28,58 +28,58 @@
 
 using NUnit.Framework;
 
-using System;
+using System;
 using System.Reflection;
 using System.Security;
-using System.Security.Permissions;
-using Microsoft.Win32;
-
-using MonoTests.System;
+using System.Security.Permissions;
+using Microsoft.Win32;
 
-namespace MonoCasTests.System {
-
-       [TestFixture]
-       [Category ("CAS")]
-       public class UriBuilderCas {
-
-               [SetUp]
-               public virtual void SetUp ()
-               {
-                       if (!SecurityManager.SecurityEnabled)
-                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
-               }
-
-               [Test]
-               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
-               public void UnitTestReuse ()
-               {
-                       UriBuilderTest unit = new UriBuilderTest ();
-                       unit.Constructor_Empty ();
-                       unit.Constructor_5 ();
-                       unit.Equals ();
-                       unit.EmptyQuery ();
-
-                       unit.GetReady ();
-                       unit.Path ();
-                       unit.Query ();
-                       unit.Fragment ();
-                       unit.Scheme ();
-
-                       unit.GetReady ();
-                       unit.ToStringTest ();
-#if NET_2_0
-                       unit.GetReady ();
-                       unit.DefaultPort ();
-#endif
-               }
-
-               [Test]
-               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
-               public void LinkDemand_Deny_Unrestricted ()
-               {
-                       ConstructorInfo ci = typeof (UriBuilder).GetConstructor 
(new Type [0]);
-                       Assert.IsNotNull (ci, "default .ctor");
-                       Assert.IsNotNull (ci.Invoke (null), "invoke");
-               }
-       }
-}
+using MonoTests.System;
+
+namespace MonoCasTests.System {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class UriBuilderCas {
+
+               [SetUp]
+               public virtual void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled 
is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void UnitTestReuse ()
+               {
+                       UriBuilderTest unit = new UriBuilderTest ();
+                       unit.Constructor_Empty ();
+                       unit.Constructor_5 ();
+                       unit.Equals ();
+                       unit.EmptyQuery ();
+
+                       unit.GetReady ();
+                       unit.Path ();
+                       unit.Query ();
+                       unit.Fragment ();
+                       unit.Scheme ();
+
+                       unit.GetReady ();
+                       unit.ToStringTest ();
+#if NET_2_0
+                       unit.GetReady ();
+                       unit.DefaultPort ();
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       ConstructorInfo ci = typeof (UriBuilder).GetConstructor 
(new Type [0]);
+                       Assert.IsNotNull (ci, "default .ctor");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+       }
+}

Modified: trunk/mcs/class/System/Test/System/UriBuilderTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System/UriBuilderTest.cs        2005-11-25 
15:32:19 UTC (rev 53478)
+++ trunk/mcs/class/System/Test/System/UriBuilderTest.cs        2005-11-25 
15:39:15 UTC (rev 53479)
@@ -1,199 +1,201 @@
-//
-// UriBuilderTest.cs - NUnit Test Cases for System.UriBuilder
-//
-// Authors:
-//   Lawrence Pit ([EMAIL PROTECTED])
-//   Martin Willemoes Hansen ([EMAIL PROTECTED])
-//
-// (C) 2003 Martin Willemoes Hansen
-//
-
-using NUnit.Framework;
-using System;
-
-namespace MonoTests.System
-{
-       [TestFixture]
-       public class UriBuilderTest : Assertion
-       {
-               private UriBuilder b, b2, b3;
-               
-               [SetUp]
-               public void GetReady()
-               {
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"foo/bar/index.html");
-               }
-
-               [Test]
-               public void Constructor_Empty ()
-               {
-                       b = new UriBuilder ();
-                       AssertEquals ("#1", "http", b.Scheme);
-#if NET_2_0
-                       AssertEquals ("#2", "localhost", b.Host);
-#else
-                       AssertEquals ("#2", "loopback", b.Host);
-#endif
-                       AssertEquals ("#3", -1, b.Port);
-               }
-
-               [Test]
-               public void Constructor_5 ()
-               {
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"foo/bar/index.html", "#extras");
-               }
-
-               [Test]
-               [ExpectedException (typeof (ArgumentException))]
-               public void Constructor_5_BadExtraValue ()
-               {
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"foo/bar/index.html", "extras");
-                       // should have thrown an ArgumentException because 
extraValue must start with '?' or '#' character.
-               }
-               
-               [Test]
-               // This test does not make sense, will fix soon
-               [Category ("NotWorking")] // bug #75144
-               public void UserInfo ()
-               {                       
-                       b = new UriBuilder ("mailto://myname:[EMAIL 
PROTECTED]");
-#if NET_2_0
-                       AssertEquals ("#1", String.Empty, b.UserName);
-                       AssertEquals ("#2", String.Empty, b.Password);
-#else
-                       AssertEquals ("#1", "myname", b.UserName);
-                       AssertEquals ("#2", "mypwd", b.Password);
-#endif                 
-                       b = new UriBuilder ("mailto", "contoso.com");
-                       b.UserName = "myname";
-                       b.Password = "mypwd";
-                       AssertEquals ("#3", "myname:mypwd", b.Uri.UserInfo);
-               }
-
-               [Test]
-               public void Path ()
-               {                       
-                       b.Path = ((char) 0xa9) + " 2002";
-                       AssertEquals ("#1", "%C2%A9%202002", b.Path);           
        
-               }       
-               
-               [Test]
-               [ExpectedException (typeof (ArgumentOutOfRangeException))]
-               public void BadPort1 ()
-               {
-                       b.Port = -12345;
-               }
-#if NET_2_0
-               [Test]
-               public void DefaultPort ()
-               {
-                       b.Port = -1;
-                       AssertEquals ("Port", -1, b.Port);
-                       AssertEquals ("ToString", 
"http://www.ximian.com/foo/bar/index.html";, b.ToString ());
-               }
-#else
-               [Test]
-               [ExpectedException (typeof (ArgumentOutOfRangeException))]
-               public void BadPort3 ()
-               {
-                       b.Port = -1;
-               }
-#endif
-               [Test]
-               public void Query ()
-               {
-                       b.Query = ((char) 0xa9) + " 2002";
-                       AssertEquals ("#1", "?\xA9 2002", b.Query);             
        
-                       AssertEquals ("#2", String.Empty, b.Fragment);
-                       b.Query = "?test";
-                       AssertEquals ("#3", "??test", b.Query);
-                       b.Query = null;
-                       AssertEquals ("#4", String.Empty, b.Query);
-               }
-               
-               [Test]
-               public void Fragment ()
-               {
-                       b.Fragment = ((char) 0xa9) + " 2002";
-                       AssertEquals ("#1", "#\xA9 2002", b.Fragment);
-                       AssertEquals ("#2", String.Empty, b.Query);
-                       b.Fragment = "#test";
-                       AssertEquals ("#3", "##test", b.Fragment);
-                       b.Fragment = null;
-                       AssertEquals ("#4", String.Empty, b.Fragment);
-               }
-               
-               [Test]
-               public void Scheme ()
-               {
-                       b.Scheme = "http";
-                       AssertEquals ("#1", b.Scheme, "http");
-                       b.Scheme = "http:";
-                       AssertEquals ("#2", b.Scheme, "http");
-                       b.Scheme = "http://";;
-                       AssertEquals ("#3", b.Scheme, "http");
-                       b.Scheme = "http://foo/bar";;
-                       AssertEquals ("#4", b.Scheme, "http");
-                       b.Scheme = "mailto:";;
-                       AssertEquals ("#5", b.Scheme, "mailto");
-                       b.Scheme = "unknown";
-                       AssertEquals ("#6", b.Scheme, "unknown");
-                       b.Scheme = "unknown://";
-                       AssertEquals ("#7", b.Scheme, "unknown");
-               }
-               
-               [Test]
-#if NET_2_0
-               [Category ("NotWorking")] // equals changed in 2.0
-#endif
-               public void Equals ()
-               {
-                       b = new UriBuilder ("http://";, "www.ximian.com", 80, 
"foo/bar/index.html?item=1");
-                       b2 = new UriBuilder ("http", "www.ximian.com", 80, 
"/foo/bar/index.html", "?item=1");
-                       b3 = new UriBuilder (new Uri 
("http://www.ximian.com/foo/bar/index.html?item=1";));
-#if NET_2_0
-                       Assert ("#1", !b.Equals (b2));
-                       Assert ("#2", !b.Uri.Equals (b2.Uri));
-                       Assert ("#3", !b.Equals (b3));
-                       Assert ("#5", !b3.Equals (b));
-#else
-                       Assert ("#1", b.Equals (b2));
-                       Assert ("#2", b.Uri.Equals (b2.Uri));
-                       Assert ("#3", b.Equals (b3));
-                       Assert ("#5", b3.Equals (b));
-#endif
-                       Assert ("#4", b2.Equals (b3));
-               }
-               
-               [Test]
-               public void ToStringTest ()
-               {
-                       AssertEquals ("ToString ()", 
"http://www.ximian.com:80/foo/bar/index.html";, b.ToString ());
-                       AssertEquals ("Uri.ToString ()", 
"http://www.ximian.com/foo/bar/index.html";, b.Uri.ToString ());
-               }
-
-               [Test]
-               public void EmptyQuery () // bug 57082
-               {
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", null);
-                       string noquery = 
"http://www.ximian.com/lalala/lelele.aspx";;
-                       AssertEquals ("#01", b.Uri.ToString (), noquery);
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", "?");
-                       AssertEquals ("#02", b.Uri.ToString (), noquery);
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", "??");
-                       AssertEquals ("#03", b.Uri.ToString (), noquery + "??");
-                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", "?something");
-                       AssertEquals ("#04", b.Uri.ToString (), noquery + 
"?something");
-               }
-
-               [Test] // bug #76501
-               public void TestToString76501 ()
-               {
-                       UriBuilder ub = new UriBuilder (
-                               "http://mondomaine/trucmuche/login.aspx";);
-                       ub.Query = ub.Query.TrimStart (new char [] {'?'}) + 
"&ticket=bla";
-                       Assert (ub.ToString ().IndexOf ("80//") < 0);
-               }
-       }
-}
-
+//
+// UriBuilderTest.cs - NUnit Test Cases for System.UriBuilder
+//
+// Authors:
+//   Lawrence Pit ([EMAIL PROTECTED])
+//   Martin Willemoes Hansen ([EMAIL PROTECTED])
+//
+// (C) 2003 Martin Willemoes Hansen
+//
+
+using NUnit.Framework;
+using System;
+
+namespace MonoTests.System
+{
+       [TestFixture]
+       public class UriBuilderTest : Assertion
+       {
+               private UriBuilder b, b2, b3;
+               
+               [SetUp]
+               public void GetReady()
+               {
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"foo/bar/index.html");
+               }
+
+               [Test]
+               public void Constructor_Empty ()
+               {
+                       b = new UriBuilder ();
+                       AssertEquals ("#1", "http", b.Scheme);
+#if NET_2_0
+                       AssertEquals ("#2", "localhost", b.Host);
+#else
+                       AssertEquals ("#2", "loopback", b.Host);
+#endif
+                       AssertEquals ("#3", -1, b.Port);
+               }
+
+               [Test]
+               public void Constructor_5 ()
+               {
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"foo/bar/index.html", "#extras");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void Constructor_5_BadExtraValue ()
+               {
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"foo/bar/index.html", "extras");
+                       // should have thrown an ArgumentException because 
extraValue must start with '?' or '#' character.
+               }
+               
+               [Test]
+               // This test does not make sense, will fix soon
+               [Category ("NotWorking")] // bug #75144
+               public void UserInfo ()
+               {                       
+                       b = new UriBuilder ("mailto://myname:[EMAIL 
PROTECTED]");
+#if NET_2_0
+                       AssertEquals ("#1", String.Empty, b.UserName);
+                       AssertEquals ("#2", String.Empty, b.Password);
+#else
+                       // NotWorking here for 1.x (bad behaviour in 1.x - may 
not be worth fixing)
+                       AssertEquals ("#1", "myname", b.UserName);
+                       AssertEquals ("#2", "mypwd", b.Password);
+#endif                 
+                       b = new UriBuilder ("mailto", "contoso.com");
+                       b.UserName = "myname";
+                       b.Password = "mypwd";
+                       // NotWorking here for 2.0 - worth fixing
+                       AssertEquals ("#3", "myname:mypwd", b.Uri.UserInfo);
+               }
+
+               [Test]
+               public void Path ()
+               {                       
+                       b.Path = ((char) 0xa9) + " 2002";
+                       AssertEquals ("#1", "%C2%A9%202002", b.Path);           
        
+               }       
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void BadPort1 ()
+               {
+                       b.Port = -12345;
+               }
+#if NET_2_0
+               [Test]
+               public void DefaultPort ()
+               {
+                       b.Port = -1;
+                       AssertEquals ("Port", -1, b.Port);
+                       AssertEquals ("ToString", 
"http://www.ximian.com/foo/bar/index.html";, b.ToString ());
+               }
+#else
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void BadPort3 ()
+               {
+                       b.Port = -1;
+               }
+#endif
+               [Test]
+               public void Query ()
+               {
+                       b.Query = ((char) 0xa9) + " 2002";
+                       AssertEquals ("#1", "?\xA9 2002", b.Query);             
        
+                       AssertEquals ("#2", String.Empty, b.Fragment);
+                       b.Query = "?test";
+                       AssertEquals ("#3", "??test", b.Query);
+                       b.Query = null;
+                       AssertEquals ("#4", String.Empty, b.Query);
+               }
+               
+               [Test]
+               public void Fragment ()
+               {
+                       b.Fragment = ((char) 0xa9) + " 2002";
+                       AssertEquals ("#1", "#\xA9 2002", b.Fragment);
+                       AssertEquals ("#2", String.Empty, b.Query);
+                       b.Fragment = "#test";
+                       AssertEquals ("#3", "##test", b.Fragment);
+                       b.Fragment = null;
+                       AssertEquals ("#4", String.Empty, b.Fragment);
+               }
+               
+               [Test]
+               public void Scheme ()
+               {
+                       b.Scheme = "http";
+                       AssertEquals ("#1", b.Scheme, "http");
+                       b.Scheme = "http:";
+                       AssertEquals ("#2", b.Scheme, "http");
+                       b.Scheme = "http://";;
+                       AssertEquals ("#3", b.Scheme, "http");
+                       b.Scheme = "http://foo/bar";;
+                       AssertEquals ("#4", b.Scheme, "http");
+                       b.Scheme = "mailto:";;
+                       AssertEquals ("#5", b.Scheme, "mailto");
+                       b.Scheme = "unknown";
+                       AssertEquals ("#6", b.Scheme, "unknown");
+                       b.Scheme = "unknown://";
+                       AssertEquals ("#7", b.Scheme, "unknown");
+               }
+               
+               [Test]
+#if NET_2_0
+               [Category ("NotWorking")] // equals changed in 2.0
+#endif
+               public void Equals ()
+               {
+                       b = new UriBuilder ("http://";, "www.ximian.com", 80, 
"foo/bar/index.html?item=1");
+                       b2 = new UriBuilder ("http", "www.ximian.com", 80, 
"/foo/bar/index.html", "?item=1");
+                       b3 = new UriBuilder (new Uri 
("http://www.ximian.com/foo/bar/index.html?item=1";));
+#if NET_2_0
+                       Assert ("#1", !b.Equals (b2));
+                       Assert ("#2", !b.Uri.Equals (b2.Uri));
+                       Assert ("#3", !b.Equals (b3));
+                       Assert ("#5", !b3.Equals (b));
+#else
+                       Assert ("#1", b.Equals (b2));
+                       Assert ("#2", b.Uri.Equals (b2.Uri));
+                       Assert ("#3", b.Equals (b3));
+                       Assert ("#5", b3.Equals (b));
+#endif
+                       Assert ("#4", b2.Equals (b3));
+               }
+               
+               [Test]
+               public void ToStringTest ()
+               {
+                       AssertEquals ("ToString ()", 
"http://www.ximian.com:80/foo/bar/index.html";, b.ToString ());
+                       AssertEquals ("Uri.ToString ()", 
"http://www.ximian.com/foo/bar/index.html";, b.Uri.ToString ());
+               }
+
+               [Test]
+               public void EmptyQuery () // bug 57082
+               {
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", null);
+                       string noquery = 
"http://www.ximian.com/lalala/lelele.aspx";;
+                       AssertEquals ("#01", b.Uri.ToString (), noquery);
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", "?");
+                       AssertEquals ("#02", b.Uri.ToString (), noquery);
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", "??");
+                       AssertEquals ("#03", b.Uri.ToString (), noquery + "??");
+                       b = new UriBuilder ("http", "www.ximian.com", 80, 
"/lalala/lelele.aspx", "?something");
+                       AssertEquals ("#04", b.Uri.ToString (), noquery + 
"?something");
+               }
+
+               [Test] // bug #76501
+               public void TestToString76501 ()
+               {
+                       UriBuilder ub = new UriBuilder (
+                               "http://mondomaine/trucmuche/login.aspx";);
+                       ub.Query = ub.Query.TrimStart (new char [] {'?'}) + 
"&ticket=bla";
+                       Assert (ub.ToString ().IndexOf ("80//") < 0);
+               }
+       }
+}
+

Modified: trunk/mcs/class/System/Test/System/UriParserTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System/UriParserTest.cs 2005-11-25 15:32:19 UTC 
(rev 53478)
+++ trunk/mcs/class/System/Test/System/UriParserTest.cs 2005-11-25 15:39:15 UTC 
(rev 53479)
@@ -35,7 +35,7 @@
 
 namespace MonoTests.System {
 
-       public class UnitTestUriParser : UriParser {
+       public class UnitTestUriParser: UriParser {
 
                private string scheme_name;
                private int default_port;
@@ -51,16 +51,28 @@
                        throw_on_register = throwOnRegister;
                }
 
-               public string SchemeName {
-                       get { return scheme_name; }
+               public string SchemeName
+               {
+                       get
+                       {
+                               return scheme_name;
+                       }
                }
 
-               public int DefaultPort {
-                       get { return default_port; }
+               public int DefaultPort
+               {
+                       get
+                       {
+                               return default_port;
+                       }
                }
 
-               public bool OnNewUriCalled {
-                       get { return on_new_uri_called; }
+               public bool OnNewUriCalled
+               {
+                       get
+                       {
+                               return on_new_uri_called;
+                       }
                }
 
                public string _GetComponents (Uri uri, UriComponents 
components, UriFormat format)
@@ -117,33 +129,89 @@
        [TestFixture]
        public class UriParserTest {
 
+               private const string full_http = 
"http://www.mono-project.com/Main_Page#FAQ?Edit";;
+
                private string prefix;
                private Uri http;
+               private Uri ftp;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        prefix = "unit.test.";
-                       http = new Uri ("http://www.mono-project.com";);
+                       http = new Uri (full_http);
+                       ftp = new Uri ("ftp://username:[EMAIL 
PROTECTED]:21/with some spaces/mono.tgz");
                }
 
-               public string Prefix {
-                       get { return prefix; }
-                       set { prefix = value; }
+               public string Prefix
+               {
+                       get
+                       {
+                               return prefix;
+                       }
+                       set
+                       {
+                               prefix = value;
+                       }
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GetComponents ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
-                       Assert.AreEqual ("www.mono-project.com", 
p._GetComponents (http, UriComponents.Host, UriFormat.SafeUnescaped), "http");
+                       Assert.AreEqual ("http", p._GetComponents (http, 
UriComponents.Scheme, UriFormat.SafeUnescaped), "http.Scheme");
+                       Assert.AreEqual (String.Empty, p._GetComponents (http, 
UriComponents.UserInfo, UriFormat.SafeUnescaped), "http.UserInfo");
+                       Assert.AreEqual ("www.mono-project.com", 
p._GetComponents (http, UriComponents.Host, UriFormat.SafeUnescaped), 
"http.Host");
+                       Assert.AreEqual (String.Empty, p._GetComponents (http, 
UriComponents.Port, UriFormat.SafeUnescaped), "http.Port");
+                       Assert.AreEqual ("Main_Page", p._GetComponents (http, 
UriComponents.Path, UriFormat.SafeUnescaped), "http.Path");
+                       Assert.AreEqual (String.Empty, p._GetComponents (http, 
UriComponents.Query, UriFormat.SafeUnescaped), "http.Query");
+                       Assert.AreEqual ("FAQ?Edit", p._GetComponents (http, 
UriComponents.Fragment, UriFormat.SafeUnescaped), "http.Fragment");
+                       Assert.AreEqual ("80", p._GetComponents (http, 
UriComponents.StrongPort, UriFormat.SafeUnescaped), "http.StrongPort");
+                       Assert.AreEqual (String.Empty, p._GetComponents (http, 
UriComponents.KeepDelimiter, UriFormat.SafeUnescaped), "http.KeepDelimiter");
+                       Assert.AreEqual ("www.mono-project.com:80", 
p._GetComponents (http, UriComponents.HostAndPort, UriFormat.SafeUnescaped), 
"http.HostAndPort");
+                       Assert.AreEqual ("www.mono-project.com:80", 
p._GetComponents (http, UriComponents.StrongAuthority, 
UriFormat.SafeUnescaped), "http.StrongAuthority");
+                       Assert.AreEqual (full_http, p._GetComponents (http, 
UriComponents.AbsoluteUri, UriFormat.SafeUnescaped), "http.AbsoluteUri");
+                       Assert.AreEqual ("/Main_Page", p._GetComponents (http, 
UriComponents.PathAndQuery, UriFormat.SafeUnescaped), "http.PathAndQuery");
+                       Assert.AreEqual 
("http://www.mono-project.com/Main_Page";, p._GetComponents (http, 
UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped), "http.HttpRequestUrl");
+                       Assert.AreEqual ("http://www.mono-project.com";, 
p._GetComponents (http, UriComponents.SchemeAndServer, 
UriFormat.SafeUnescaped), "http.SchemeAndServer");
+                       Assert.AreEqual (full_http, p._GetComponents (http, 
UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), 
"http.SerializationInfoString");
+                       // strange mixup
+                       Assert.AreEqual ("http://";, p._GetComponents (http, 
UriComponents.Scheme | UriComponents.Port, UriFormat.SafeUnescaped), 
"http.Scheme+Port");
+                       Assert.AreEqual ("www.mono-project.com#FAQ?Edit", 
p._GetComponents (http, UriComponents.Host | UriComponents.Fragment, 
UriFormat.SafeUnescaped), "http.Scheme+Port");
+                       Assert.AreEqual ("/Main_Page", p._GetComponents (http, 
UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped), 
"http.Scheme+Port");
                        Assert.AreSame (p, p._OnNewUri (), "OnNewUri");
                }
 
                [Test]
+               public void GetComponents_Ftp ()
+               {
+                       UnitTestUriParser p = new UnitTestUriParser ();
+                       Assert.AreEqual ("ftp", p._GetComponents (ftp, 
UriComponents.Scheme, UriFormat.Unescaped), "ftp.Scheme");
+                       Assert.AreEqual ("username:password", p._GetComponents 
(ftp, UriComponents.UserInfo, UriFormat.Unescaped), "ftp.UserInfo");
+                       Assert.AreEqual ("ftp.go-mono.com", p._GetComponents 
(ftp, UriComponents.Host, UriFormat.Unescaped), "ftp.Host");
+                       Assert.AreEqual (String.Empty, p._GetComponents (ftp, 
UriComponents.Port, UriFormat.Unescaped), "ftp.Port");
+                       Assert.AreEqual ("with some spaces/mono.tgz", 
p._GetComponents (ftp, UriComponents.Path, UriFormat.Unescaped), "ftp.Path");
+                       Assert.AreEqual ("with%20some%20spaces/mono.tgz", 
p._GetComponents (ftp, UriComponents.Path, UriFormat.UriEscaped), 
"ftp.Path-UriEscaped");
+                       Assert.AreEqual ("with some spaces/mono.tgz", 
p._GetComponents (ftp, UriComponents.Path, UriFormat.SafeUnescaped), 
"ftp.Path-SafeUnescaped");
+                       Assert.AreEqual (String.Empty, p._GetComponents (ftp, 
UriComponents.Query, UriFormat.Unescaped), "ftp.Query");
+                       Assert.AreEqual (String.Empty, p._GetComponents (ftp, 
UriComponents.Fragment, UriFormat.Unescaped), "ftp.Fragment");
+                       Assert.AreEqual ("21", p._GetComponents (ftp, 
UriComponents.StrongPort, UriFormat.Unescaped), "ftp.StrongPort");
+                       Assert.AreEqual (String.Empty, p._GetComponents (ftp, 
UriComponents.KeepDelimiter, UriFormat.Unescaped), "http.KeepDelimiter");
+                       Assert.AreEqual ("ftp.go-mono.com:21", p._GetComponents 
(ftp, UriComponents.HostAndPort, UriFormat.Unescaped), "http.HostAndPort");
+                       Assert.AreEqual ("username:[EMAIL PROTECTED]:21", 
p._GetComponents (ftp, UriComponents.StrongAuthority, UriFormat.Unescaped), 
"http.StrongAuthority");
+                       Assert.AreEqual ("ftp://username:[EMAIL PROTECTED]/with 
some spaces/mono.tgz", p._GetComponents (ftp, UriComponents.AbsoluteUri, 
UriFormat.Unescaped), "http.AbsoluteUri");
+                       Assert.AreEqual ("/with some spaces/mono.tgz", 
p._GetComponents (ftp, UriComponents.PathAndQuery, UriFormat.Unescaped), 
"http.PathAndQuery");
+                       Assert.AreEqual ("ftp://ftp.go-mono.com/with some 
spaces/mono.tgz", p._GetComponents (ftp, UriComponents.HttpRequestUrl, 
UriFormat.Unescaped), "http.HttpRequestUrl");
+                       Assert.AreEqual ("ftp://ftp.go-mono.com";, 
p._GetComponents (ftp, UriComponents.SchemeAndServer, UriFormat.Unescaped), 
"http.SchemeAndServer");
+                       Assert.AreEqual ("ftp://username:[EMAIL PROTECTED]/with 
some spaces/mono.tgz", p._GetComponents (ftp, 
UriComponents.SerializationInfoString, UriFormat.Unescaped), 
"http.SerializationInfoString");
+                       Assert.AreSame (p, p._OnNewUri (), "OnNewUri");
+                       // strange mixup
+                       Assert.AreEqual ("ftp://username:password@";, 
p._GetComponents (ftp, UriComponents.Scheme | UriComponents.UserInfo, 
UriFormat.Unescaped), "ftp.Scheme+UserInfo");
+                       Assert.AreEqual (":21/with some spaces/mono.tgz", 
p._GetComponents (ftp, UriComponents.Path | UriComponents.StrongPort, 
UriFormat.Unescaped), "ftp.Path+StrongPort");
+               }
+
+               [Test]
                [ExpectedException (typeof (NullReferenceException))]
-               [Category ("NotWorking")]
                public void GetComponents_Null ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
@@ -151,11 +219,10 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GetComponents_BadUriComponents ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
-                       Assert.AreEqual ("http://www.mono-project.com/";, 
p._GetComponents (http, (UriComponents) Int32.MinValue, 
UriFormat.SafeUnescaped), "http");
+                       Assert.AreEqual (full_http, p._GetComponents (http, 
(UriComponents) Int32.MinValue, UriFormat.SafeUnescaped), "http");
                }
 
                [Test]
@@ -163,7 +230,7 @@
                public void GetComponents_BadUriFormat ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
-                       p._GetComponents (http, UriComponents.Host, 
(UriFormat)Int32.MinValue);
+                       p._GetComponents (http, UriComponents.Host, (UriFormat) 
Int32.MinValue);
                }
 
                [Test]
@@ -187,16 +254,70 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void IsBaseOf ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
                        Assert.IsTrue (p._IsBaseOf (http, http), "http-http");
+
+                       Uri u = new Uri 
("http://www.mono-project.com/Main_Page#FAQ";);
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-1a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-1b");
+
+                       u = new Uri ("http://www.mono-project.com/Main_Page";);
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-2a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-2b");
+
+                       u = new Uri ("http://www.mono-project.com/";);
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-3a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-3b");
+
+                       u = new Uri ("http://www.mono-project.com/Main_Page/";);
+                       Assert.IsFalse (p._IsBaseOf (u, http), "http-4a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-4b");
+
+                       // docs says the UserInfo isn't evaluated, but...
+                       u = new Uri ("http://username:[EMAIL 
PROTECTED]/Main_Page");
+                       Assert.IsFalse (p._IsBaseOf (u, http), "http-5a");
+                       Assert.IsFalse (p._IsBaseOf (http, u), "http-5b");
+
+                       // scheme case sensitive ? no
+                       u = new Uri ("HTTP://www.mono-project.com/Main_Page");
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-6a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-6b");
+
+                       // host case sensitive ? no
+                       u = new Uri ("http://www.Mono-Project.com/Main_Page";);
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-7a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-7b");
+
+                       // path case sensitive ? no
+                       u = new Uri ("http://www.Mono-Project.com/MAIN_Page";);
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-8a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-8b");
+
+                       // different scheme
+                       u = new Uri ("ftp://www.mono-project.com/Main_Page";);
+                       Assert.IsFalse (p._IsBaseOf (u, http), "http-9a");
+                       Assert.IsFalse (p._IsBaseOf (http, u), "http-9b");
+
+                       // different host
+                       u = new Uri ("http://www.go-mono.com/Main_Page";);
+                       Assert.IsFalse (p._IsBaseOf (u, http), "http-10a");
+                       Assert.IsFalse (p._IsBaseOf (http, u), "http-10b");
+
+                       // different port
+                       u = new Uri ("http://www.mono-project.com:8080/";);
+                       Assert.IsFalse (p._IsBaseOf (u, http), "http-11a");
+                       Assert.IsFalse (p._IsBaseOf (http, u), "http-11b");
+
+                       // specify default port
+                       u = new Uri ("http://www.mono-project.com:80/";);
+                       Assert.IsTrue (p._IsBaseOf (u, http), "http-12a");
+                       Assert.IsTrue (p._IsBaseOf (http, u), "http-12b");
                }
 
                [Test]
                [ExpectedException (typeof (NullReferenceException))]
-               [Category ("NotWorking")]
                public void IsBaseOf_UriNull ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
@@ -205,7 +326,6 @@
 
                [Test]
                [ExpectedException (typeof (NullReferenceException))]
-               [Category ("NotWorking")]
                public void IsBaseOf_NullUri ()
                {
                        UnitTestUriParser p = new UnitTestUriParser ();
@@ -266,7 +386,7 @@
                {
                        UriFormatException error = null;
                        UnitTestUriParser p = new UnitTestUriParser ();
-                       Assert.AreEqual ("http://www.mono-project.com";, 
p._Resolve (http, http, out error), "http-http");
+                       Assert.AreEqual (full_http, p._Resolve (http, http, out 
error), "http-http");
                }
 
                [Test]
@@ -275,7 +395,7 @@
                {
                        UriFormatException error = null;
                        UnitTestUriParser p = new UnitTestUriParser ();
-                       Assert.AreEqual ("http://www.mono-project.com";, 
p._Resolve (http, null, out error), "http-http");
+                       Assert.AreEqual (full_http, p._Resolve (http, null, out 
error), "http-http");
                }
 
                [Test]
@@ -411,4 +531,4 @@
        }
 }
 
-#endif
\ No newline at end of file
+#endif

Modified: trunk/mcs/class/System/Test/System/UriTest3.cs
===================================================================
--- trunk/mcs/class/System/Test/System/UriTest3.cs      2005-11-25 15:32:19 UTC 
(rev 53478)
+++ trunk/mcs/class/System/Test/System/UriTest3.cs      2005-11-25 15:39:15 UTC 
(rev 53479)
@@ -169,6 +169,112 @@
                        Uri uri = null;
                        Uri.TryCreate (new Uri (absolute), (Uri) null, out uri);
                }
+
+               [Test]
+               public void IsWellFormedUriString_Null ()
+               {
+                       Assert.IsFalse (Uri.IsWellFormedUriString (null, 
UriKind.Absolute), "null");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void IsWellFormedUriString_Http ()
+               {
+                       Assert.IsFalse (Uri.IsWellFormedUriString 
("http://www.go-mono.com/Main Page", UriKind.Absolute), "http/space");
+                       Assert.IsTrue (Uri.IsWellFormedUriString 
("http://www.go-mono.com/Main%20Page";, UriKind.Absolute), "http/%20");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void IsWellFormedUriString_BadUriKind ()
+               {
+                       Uri.IsWellFormedUriString ("http://www.go-mono.com/Main 
Page", (UriKind)Int32.MinValue);
+               }
+
+               [Test]
+               public void Compare ()
+               {
+                       Uri u1 = null;
+                       Uri u2 = null;
+                       Assert.AreEqual (0, Uri.Compare (u1, u2, 
UriComponents.AbsoluteUri, UriFormat.UriEscaped, 
StringComparison.CurrentCulture), "null-null");
+
+                       u1 = new Uri ("http://www.go-mono.com/Main Page");
+                       u2 = new Uri ("http://www.go-mono.com/Main%20Page";);
+                       Assert.AreEqual (0, Uri.Compare (u1, u2, 
UriComponents.AbsoluteUri, UriFormat.Unescaped, 
StringComparison.CurrentCulture), "http/space-http/%20-unescaped");
+                       Assert.AreEqual (0, Uri.Compare (u1, u2, 
UriComponents.AbsoluteUri, UriFormat.UriEscaped, 
StringComparison.CurrentCulture), "http/space-http/%20-escaped");
+                       Assert.AreEqual (0, Uri.Compare (u1, u2, 
UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, 
StringComparison.CurrentCulture), "http/space-http/%20-safe");
+               }
+
+               [Test]
+               public void IsBaseOf ()
+               {
+                       Uri http = new Uri 
("http://www.mono-project.com/Main_Page#FAQ?Edit";);
+                       Assert.IsTrue (http.IsBaseOf (http), "http-http");
+
+                       Uri u = new Uri 
("http://www.mono-project.com/Main_Page#FAQ";);
+                       Assert.IsTrue (u.IsBaseOf (http), "http-1a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-1b");
+
+                       u = new Uri ("http://www.mono-project.com/Main_Page";);
+                       Assert.IsTrue (u.IsBaseOf (http), "http-2a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-2b");
+
+                       u = new Uri ("http://www.mono-project.com/";);
+                       Assert.IsTrue (u.IsBaseOf (http), "http-3a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-3b");
+
+                       u = new Uri ("http://www.mono-project.com/Main_Page/";);
+                       Assert.IsFalse (u.IsBaseOf (http), "http-4a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-4b");
+
+                       // docs says the UserInfo isn't evaluated, but...
+                       u = new Uri ("http://username:[EMAIL 
PROTECTED]/Main_Page");
+                       Assert.IsFalse (u.IsBaseOf (http), "http-5a");
+                       Assert.IsFalse (http.IsBaseOf (u), "http-5b");
+
+                       // scheme case sensitive ? no
+                       u = new Uri ("HTTP://www.mono-project.com/Main_Page");
+                       Assert.IsTrue (u.IsBaseOf (http), "http-6a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-6b");
+
+                       // host case sensitive ? no
+                       u = new Uri ("http://www.Mono-Project.com/Main_Page";);
+                       Assert.IsTrue (u.IsBaseOf (http), "http-7a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-7b");
+
+                       // path case sensitive ? no
+                       u = new Uri ("http://www.Mono-Project.com/MAIN_Page";);
+                       Assert.IsTrue (u.IsBaseOf (http), "http-8a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-8b");
+
+                       // different scheme
+                       u = new Uri ("ftp://www.mono-project.com/Main_Page";);
+                       Assert.IsFalse (u.IsBaseOf (http), "http-9a");
+                       Assert.IsFalse (http.IsBaseOf (u), "http-9b");
+
+                       // different host
+                       u = new Uri ("http://www.go-mono.com/Main_Page";);
+                       Assert.IsFalse (u.IsBaseOf (http), "http-10a");
+                       Assert.IsFalse (http.IsBaseOf (u), "http-10b");
+
+                       // different port
+                       u = new Uri ("http://www.mono-project.com:8080/";);
+                       Assert.IsFalse (u.IsBaseOf (http), "http-11a");
+                       Assert.IsFalse (http.IsBaseOf (u), "http-11b");
+
+                       // specify default port
+                       u = new Uri ("http://www.mono-project.com:80/";);
+                       Assert.IsTrue (u.IsBaseOf (http), "http-12a");
+                       Assert.IsTrue (http.IsBaseOf (u), "http-12b");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void IsBaseOf_Null ()
+               {
+                       Uri http = new Uri 
("http://www.mono-project.com/Main_Page#FAQ?Edit";);
+                       http.IsBaseOf (null);
+               }
        }
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to