* WebProxyTest.cs: Move IsBypassed null check to separate test, and
authorGert Driesen <drieseng@users.sourceforge.net>
Sun, 28 Jan 2007 13:11:58 +0000 (13:11 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Sun, 28 Jan 2007 13:11:58 +0000 (13:11 -0000)
fixed it for 2.0 profile. Added test for binary serialization.
* WebProxy.cs: Lazy init bypassList. Fixes for binary serialization
compatibility. Added stub for UseDefaultCredentials (2.0). On 2.0
profile, throw ArgumentNullException in IsBypassed if host is null.

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

mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/WebProxy.cs
mcs/class/System/Test/System.Net/ChangeLog
mcs/class/System/Test/System.Net/WebProxyTest.cs

index 2f346ac1931eb973e2ec76605dab411c1193c4ae..89ceeb5826719423b6c3e8d0cab08131f3abb5f6 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-28  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * WebProxy.cs: Lazy init bypassList. Fixes for binary serialization
+       compatibility. Added stub for UseDefaultCredentials (2.0). On 2.0
+       profile, throw ArgumentNullException in IsBypassed if host is null.
+
 2007-01-22  Miguel de Icaza  <miguel@novell.com>
 
        * HttpWebRequest.cs: Remove unused variable.
index 6d49a01c00987556daf9a7de5a7f3cb8417ae5c6..4a31deea5a91cb22b0207f5766e46be910a037f0 100644 (file)
@@ -36,11 +36,15 @@ using System.Text.RegularExpressions;
 namespace System.Net 
 {
        [Serializable]
-       public class WebProxy : IWebProxy, ISerializable {
+       public class WebProxy : IWebProxy, ISerializable
+       {
                Uri address;
                bool bypassOnLocal;
                ArrayList bypassList;
                ICredentials credentials;
+#if NET_2_0
+               bool useDefaultCredentials;
+#endif
 
                // Constructors
 
@@ -77,18 +81,20 @@ namespace System.Net
                {
                        this.address = address;
                        this.bypassOnLocal = bypassOnLocal;
-                       if (bypassList == null)
-                               bypassList = new string [] {};
-                       this.bypassList = new ArrayList (bypassList);
+                       if (bypassList != null)
+                               this.bypassList = new ArrayList (bypassList);
                        this.credentials = credentials;
                        CheckBypassList ();
                }
 
                protected WebProxy (SerializationInfo serializationInfo, StreamingContext streamingContext) 
                {
-                       this.address = (Uri) serializationInfo.GetValue ("address", typeof (Uri));
-                       this.bypassOnLocal = serializationInfo.GetBoolean ("bypassOnLocal");
-                       this.bypassList = (ArrayList) serializationInfo.GetValue ("bypassList", typeof (ArrayList));
+                       this.address = (Uri) serializationInfo.GetValue ("_ProxyAddress", typeof (Uri));
+                       this.bypassOnLocal = serializationInfo.GetBoolean ("_BypassOnLocal");
+                       this.bypassList = (ArrayList) serializationInfo.GetValue ("_BypassList", typeof (ArrayList));
+#if NET_2_0
+                       this.useDefaultCredentials =  serializationInfo.GetBoolean ("_UseDefaultCredentials");
+#endif
                        this.credentials = null;
                        CheckBypassList ();
                }
@@ -100,11 +106,15 @@ namespace System.Net
                }
 
                public ArrayList BypassArrayList {
-                       get { return bypassList; }
+                       get {
+                               if (bypassList == null)
+                                       bypassList = new ArrayList ();
+                               return bypassList;
+                       }
                }
 
                public string [] BypassList {
-                       get { return (string []) bypassList.ToArray (typeof (string)); }
+                       get { return (string []) BypassArrayList.ToArray (typeof (string)); }
                        set { 
                                if (value == null)
                                        throw new ArgumentNullException ();
@@ -123,6 +133,14 @@ namespace System.Net
                        set { credentials = value; }
                }
 
+#if NET_2_0
+               [MonoTODO ("Does not affect Credentials, since CredentialCache.DefaultCredentials is not implemented.")]
+               public bool UseDefaultCredentials {
+                       get { return useDefaultCredentials; }
+                       set { useDefaultCredentials = value; }
+               }
+#endif
+
                // Methods
                [MonoTODO("Can we get this info under windows from the system?")]
                public static WebProxy GetDefaultProxy ()
@@ -145,8 +163,10 @@ namespace System.Net
 
                public bool IsBypassed (Uri host)
                {
-                       if (address == null)
-                               return true;
+#if NET_2_0
+                       if (host == null)
+                               throw new ArgumentNullException ("host");
+#endif
 
                        if (bypassOnLocal && host.IsLoopback)
                                return true;
@@ -169,8 +189,11 @@ namespace System.Net
                                } catch {}
                        }
 
-                       try {                           
-                               string hostStr = host.Scheme + "://" + host.Authority;                          
+                       if (bypassList == null)
+                               return false;
+
+                       try {
+                               string hostStr = host.Scheme + "://" + host.Authority;
                                int i = 0;
                                for (; i < bypassList.Count; i++) {
                                        Regex regex = new Regex ((string) bypassList [i], 
@@ -199,16 +222,21 @@ namespace System.Net
                void ISerializable.GetObjectData (SerializationInfo serializationInfo,
                                                  StreamingContext streamingContext)
                {
-                       serializationInfo.AddValue ("bypassOnLocal", bypassOnLocal);
-                       serializationInfo.AddValue ("address", address);
-                       serializationInfo.AddValue ("bypassList", bypassList);
+                       serializationInfo.AddValue ("_BypassOnLocal", bypassOnLocal);
+                       serializationInfo.AddValue ("_ProxyAddress", address);
+                       serializationInfo.AddValue ("_BypassList", bypassList);
+#if NET_2_0
+                       serializationInfo.AddValue ("_UseDefaultCredentials", UseDefaultCredentials);
+#endif
                }
 
                // Private Methods
                // this compiles the regular expressions, and will throw
                // an exception when an invalid one is found.
                void CheckBypassList ()
-               {                       
+               {
+                       if (bypassList == null)
+                               return;
                        for (int i = 0; i < bypassList.Count; i++)
                                new Regex ((string) bypassList [i]);
                }
@@ -225,4 +253,3 @@ namespace System.Net
                }
        }
 }
-
index 1c35af3907b55c169d20ea05de5485e3b5044f7a..9d93f112998133d0adcfc4af8fb9b776b0d70fe6 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-28  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * WebProxyTest.cs: Move IsBypassed null check to separate test, and
+       fixed it for 2.0 profile. Added test for binary serialization.
+
 2007-01-25  Ilya Kharmatsky  <ilyak -at- mainsoft.com>
 
        * FileWebRequestTest.cs: Workaround Grasshopper's bugs with
index 0db10daf0532c42755f22a01081f9df98b2a1f01..664892a4f6dafab142148718e167ecddcfa89aeb 100644 (file)
-//\r
-// WebProxyTest.cs - NUnit Test Cases for System.Net.WebProxy\r
-//\r
-// Authors:\r
-//   Lawrence Pit (loz@cable.a2000.nl)\r
-//   Martin Willemoes Hansen (mwh@sysrq.dk)\r
-//\r
-// (C) 2003 Martin Willemoes Hansen\r
-//\r
-\r
-using NUnit.Framework;\r
-using System;\r
-using System.Collections;\r
-using System.IO;\r
-using System.Net;\r
-using System.Threading;\r
-\r
-namespace MonoTests.System.Net\r
-{\r
-\r
-[TestFixture]\r
-public class WebProxyTest\r
-{\r
-       private Uri googleUri;\r
-       private Uri yahooUri;\r
-       private Uri apacheUri;\r
-       \r
-       [SetUp]\r
-        public void GetReady () {\r
-               googleUri = new Uri ("http://www.google.com");\r
-               yahooUri = new Uri ("http://www.yahoo.com");\r
-               apacheUri = new Uri ("http://www.apache.org");\r
-       }\r
-\r
-        [Test]\r
-        public void Constructors ()\r
-        {\r
-               WebProxy p = new WebProxy ();\r
-               Assertion.Assert("#1", p.Address == null);\r
-               Assertion.AssertEquals ("#2", 0, p.BypassArrayList.Count);\r
-               Assertion.AssertEquals ("#3", 0, p.BypassList.Length);\r
-               Assertion.AssertEquals ("#4", false, p.BypassProxyOnLocal);\r
-               try {\r
-                       p.BypassList = null;\r
-                       Assertion.Fail ("#5 not spec'd, but should follow ms.net implementation");\r
-               } catch (ArgumentNullException) {}\r
-\r
-               p = new WebProxy ("webserver.com", 8080);\r
-               Assertion.AssertEquals ("#6", new Uri ("http://webserver.com:8080/"), p.Address);\r
-               \r
-               p = new WebProxy ("webserver");\r
-               Assertion.AssertEquals ("#7", new Uri ("http://webserver"), p.Address);\r
-\r
-               p = new WebProxy ("webserver.com");\r
-               Assertion.AssertEquals ("#8", new Uri ("http://webserver.com"), p.Address);\r
-\r
-               p = new WebProxy ("http://webserver.com");\r
-               Assertion.AssertEquals ("#9", new Uri ("http://webserver.com"), p.Address);\r
-\r
-               p = new WebProxy ("file://webserver");\r
-               Assertion.AssertEquals ("#10", new Uri ("file://webserver"), p.Address);                \r
-               \r
-               p = new WebProxy ("http://www.contoso.com", true, null, null);\r
-               Assertion.AssertEquals ("#11", 0, p.BypassList.Length);\r
-               Assertion.AssertEquals ("#12", 0, p.BypassArrayList.Count);\r
-               \r
-               try {\r
-                       p = new WebProxy ("http://contoso.com", true, \r
-                               new string [] {"?^!@#$%^&}{]["}, null);\r
-                       Assertion.Fail ("#13: illegal regular expression");\r
-               } catch (ArgumentException) {\r
-               }\r
-       }\r
-       \r
-        [Test]\r
-       public void BypassArrayList ()\r
-       {\r
-               Uri proxy1 = new Uri("http://proxy.contoso.com");\r
-               Uri proxy2 = new Uri ("http://proxy2.contoso.com");\r
-               \r
-               WebProxy p = new WebProxy (proxy1, true);\r
-               p.BypassArrayList.Add ("http://proxy2.contoso.com");\r
-               p.BypassArrayList.Add ("http://proxy2.contoso.com");            \r
-               Assertion.AssertEquals ("#1", 2, p.BypassList.Length);\r
-               Assertion.Assert ("#2", !p.IsBypassed (new Uri ("http://www.google.com")));\r
-               Assertion.Assert ("#3", p.IsBypassed (proxy2));\r
-               Assertion.AssertEquals ("#4", proxy2, p.GetProxy (proxy2));\r
-\r
-               p.BypassArrayList.Add ("?^!@#$%^&}{][");\r
-               Assertion.AssertEquals ("#10", 3, p.BypassList.Length);\r
-               try {\r
-                       Assertion.Assert ("#11", !p.IsBypassed (proxy2));\r
-                       Assertion.Assert ("#12", !p.IsBypassed (new Uri ("http://www.x.com")));         \r
-                       Assertion.AssertEquals ("#13", proxy1, p.GetProxy (proxy2));\r
-                       // hmm... although #11 and #13 succeeded before (#3 resp. #4), \r
-                       // it now fails to bypass, and the IsByPassed and GetProxy \r
-                       // methods do not fail.. so when an illegal regular \r
-                       // expression is added through this property it's ignored. \r
-                       // probably an ms.net bug?? :(\r
-               } catch (ArgumentException) {\r
-                       Assertion.Fail ("#15: illegal regular expression");\r
-               }               \r
-       }\r
-       \r
-        [Test]\r
-       public void BypassList ()\r
-       {\r
-               Uri proxy1 = new Uri("http://proxy.contoso.com");\r
-               Uri proxy2 = new Uri ("http://proxy2.contoso.com");\r
-               \r
-               WebProxy p = new WebProxy (proxy1, true);\r
-               try {\r
-                       p.BypassList = new string [] {"http://proxy2.contoso.com", "?^!@#$%^&}{]["};            \r
-                       Assertion.Fail ("#1");\r
-               } catch (ArgumentException) {\r
-                       // weird, this way invalid regex's fail again..\r
-               }\r
-               \r
-               Assertion.AssertEquals ("#2", 2, p.BypassList.Length);\r
-               // but it did apparenly store the regex's !\r
-\r
-               p.BypassList = new string [] {"http://www.x.com"};              \r
-               Assertion.AssertEquals ("#3", 1, p.BypassList.Length);\r
-\r
-               try {\r
-                       p.BypassList = null;\r
-                       Assertion.Fail ("#4");\r
-               } catch (ArgumentNullException) {}\r
-               \r
-               Assertion.AssertEquals ("#4", 1, p.BypassList.Length);          \r
-       }\r
-       \r
-        [Test]\r
-       public void GetProxy ()\r
-       {\r
-       }       \r
-       \r
-        [Test]\r
-       public void IsByPassed ()\r
-       {\r
-               WebProxy p = new WebProxy ("http://proxy.contoso.com", true);\r
-               Assertion.Assert ("#1", !p.IsBypassed (new Uri ("http://www.google.com")));\r
-               Assertion.Assert ("#2", p.IsBypassed (new Uri ("http://localhost/index.html")));\r
-               Assertion.Assert ("#3", p.IsBypassed (new Uri ("http://localhost:8080/index.html")));\r
-               Assertion.Assert ("#4", p.IsBypassed (new Uri ("http://loopback:8080/index.html")));\r
-               Assertion.Assert ("#5", p.IsBypassed (new Uri ("http://127.0.0.01:8080/index.html")));\r
-               Assertion.Assert ("#6", p.IsBypassed (new Uri ("http://webserver/index.html")));\r
-               Assertion.Assert ("#7", !p.IsBypassed (new Uri ("http://webserver.com/index.html")));\r
-               try {\r
-                       p.IsBypassed (null);\r
-                       Assertion.Fail ("#8 not spec'd, but should follow ms.net implementation");\r
-               } catch (NullReferenceException) {}\r
-               \r
-               p = new WebProxy ("http://proxy.contoso.com", false);\r
-               Assertion.Assert ("#11", !p.IsBypassed (new Uri ("http://www.google.com")));\r
-               Assertion.Assert ("#12: lamespec of ms.net", p.IsBypassed (new Uri ("http://localhost/index.html")));\r
-               Assertion.Assert ("#13: lamespec of ms.net", p.IsBypassed (new Uri ("http://localhost:8080/index.html")));\r
-               Assertion.Assert ("#14: lamespec of ms.net", p.IsBypassed (new Uri ("http://loopback:8080/index.html")));\r
-               Assertion.Assert ("#15: lamespec of ms.net", p.IsBypassed (new Uri ("http://127.0.0.01:8080/index.html")));\r
-               Assertion.Assert ("#16", !p.IsBypassed (new Uri ("http://webserver/index.html")));\r
-               \r
-               p.BypassList = new string [] { "google.com", "contoso.com" };\r
-               Assertion.Assert ("#20", p.IsBypassed (new Uri ("http://www.google.com")));\r
-               Assertion.Assert ("#21", p.IsBypassed (new Uri ("http://www.GOOGLE.com")));\r
-               Assertion.Assert ("#22", p.IsBypassed (new Uri ("http://www.contoso.com:8080/foo/bar/index.html")));\r
-               Assertion.Assert ("#23", !p.IsBypassed (new Uri ("http://www.contoso2.com:8080/foo/bar/index.html")));\r
-               Assertion.Assert ("#24", !p.IsBypassed (new Uri ("http://www.foo.com:8080/contoso.com.html")));\r
-               \r
-               p.BypassList = new string [] { "https" };               \r
-               Assertion.Assert ("#30", !p.IsBypassed (new Uri ("http://www.google.com")));\r
-               Assertion.Assert ("#31", p.IsBypassed (new Uri ("https://www.google.com")));\r
-       }\r
-}\r
-\r
-}\r
-\r
+//
+// WebProxyTest.cs - NUnit Test Cases for System.Net.WebProxy
+//
+// Authors:
+//   Lawrence Pit (loz@cable.a2000.nl)
+//   Martin Willemoes Hansen (mwh@sysrq.dk)
+//   Gert Driesen (drieseng@users.sourceforge.net)
+//
+// (C) 2003 Martin Willemoes Hansen
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Net
+{
+       [TestFixture]
+       public class WebProxyTest
+       {
+               private Uri googleUri;
+               private Uri yahooUri;
+               private Uri apacheUri;
+
+               [SetUp]
+               public void GetReady ()
+               {
+                       googleUri = new Uri ("http://www.google.com");
+                       yahooUri = new Uri ("http://www.yahoo.com");
+                       apacheUri = new Uri ("http://www.apache.org");
+               }
+
+               [Test]
+               public void Constructors ()
+               {
+                       WebProxy p = new WebProxy ();
+                       Assertion.Assert ("#1", p.Address == null);
+                       Assertion.AssertEquals ("#2", 0, p.BypassArrayList.Count);
+                       Assertion.AssertEquals ("#3", 0, p.BypassList.Length);
+                       Assertion.AssertEquals ("#4", false, p.BypassProxyOnLocal);
+                       try {
+                               p.BypassList = null;
+                               Assertion.Fail ("#5 not spec'd, but should follow ms.net implementation");
+                       } catch (ArgumentNullException) { }
+
+                       p = new WebProxy ("webserver.com", 8080);
+                       Assertion.AssertEquals ("#6", new Uri ("http://webserver.com:8080/"), p.Address);
+
+                       p = new WebProxy ("webserver");
+                       Assertion.AssertEquals ("#7", new Uri ("http://webserver"), p.Address);
+
+                       p = new WebProxy ("webserver.com");
+                       Assertion.AssertEquals ("#8", new Uri ("http://webserver.com"), p.Address);
+
+                       p = new WebProxy ("http://webserver.com");
+                       Assertion.AssertEquals ("#9", new Uri ("http://webserver.com"), p.Address);
+
+                       p = new WebProxy ("file://webserver");
+                       Assertion.AssertEquals ("#10", new Uri ("file://webserver"), p.Address);
+
+                       p = new WebProxy ("http://www.contoso.com", true, null, null);
+                       Assertion.AssertEquals ("#11", 0, p.BypassList.Length);
+                       Assertion.AssertEquals ("#12", 0, p.BypassArrayList.Count);
+
+                       try {
+                               p = new WebProxy ("http://contoso.com", true,
+                                       new string [] { "?^!@#$%^&}{][" }, null);
+                               Assertion.Fail ("#13: illegal regular expression");
+                       } catch (ArgumentException) {
+                       }
+               }
+
+               [Test]
+               public void BypassArrayList ()
+               {
+                       Uri proxy1 = new Uri ("http://proxy.contoso.com");
+                       Uri proxy2 = new Uri ("http://proxy2.contoso.com");
+
+                       WebProxy p = new WebProxy (proxy1, true);
+                       p.BypassArrayList.Add ("http://proxy2.contoso.com");
+                       p.BypassArrayList.Add ("http://proxy2.contoso.com");
+                       Assertion.AssertEquals ("#1", 2, p.BypassList.Length);
+                       Assertion.Assert ("#2", !p.IsBypassed (new Uri ("http://www.google.com")));
+                       Assertion.Assert ("#3", p.IsBypassed (proxy2));
+                       Assertion.AssertEquals ("#4", proxy2, p.GetProxy (proxy2));
+
+                       p.BypassArrayList.Add ("?^!@#$%^&}{][");
+                       Assertion.AssertEquals ("#10", 3, p.BypassList.Length);
+                       try {
+                               Assertion.Assert ("#11", !p.IsBypassed (proxy2));
+                               Assertion.Assert ("#12", !p.IsBypassed (new Uri ("http://www.x.com")));
+                               Assertion.AssertEquals ("#13", proxy1, p.GetProxy (proxy2));
+                               // hmm... although #11 and #13 succeeded before (#3 resp. #4), 
+                               // it now fails to bypass, and the IsByPassed and GetProxy 
+                               // methods do not fail.. so when an illegal regular 
+                               // expression is added through this property it's ignored. 
+                               // probably an ms.net bug?? :(
+                       } catch (ArgumentException) {
+                               Assertion.Fail ("#15: illegal regular expression");
+                       }
+               }
+
+               [Test]
+               public void BypassList ()
+               {
+                       Uri proxy1 = new Uri ("http://proxy.contoso.com");
+                       Uri proxy2 = new Uri ("http://proxy2.contoso.com");
+
+                       WebProxy p = new WebProxy (proxy1, true);
+                       try {
+                               p.BypassList = new string [] { "http://proxy2.contoso.com", "?^!@#$%^&}{][" };
+                               Assertion.Fail ("#1");
+                       } catch (ArgumentException) {
+                               // weird, this way invalid regex's fail again..
+                       }
+
+                       Assertion.AssertEquals ("#2", 2, p.BypassList.Length);
+                       // but it did apparenly store the regex's !
+
+                       p.BypassList = new string [] { "http://www.x.com" };
+                       Assertion.AssertEquals ("#3", 1, p.BypassList.Length);
+
+                       try {
+                               p.BypassList = null;
+                               Assertion.Fail ("#4");
+                       } catch (ArgumentNullException) { }
+
+                       Assertion.AssertEquals ("#4", 1, p.BypassList.Length);
+               }
+
+               [Test]
+               public void GetProxy ()
+               {
+               }
+
+               [Test]
+               public void IsByPassed ()
+               {
+                       WebProxy p = new WebProxy ("http://proxy.contoso.com", true);
+                       Assertion.Assert ("#1", !p.IsBypassed (new Uri ("http://www.google.com")));
+                       Assertion.Assert ("#2", p.IsBypassed (new Uri ("http://localhost/index.html")));
+                       Assertion.Assert ("#3", p.IsBypassed (new Uri ("http://localhost:8080/index.html")));
+                       Assertion.Assert ("#4", p.IsBypassed (new Uri ("http://loopback:8080/index.html")));
+                       Assertion.Assert ("#5", p.IsBypassed (new Uri ("http://127.0.0.01:8080/index.html")));
+                       Assertion.Assert ("#6", p.IsBypassed (new Uri ("http://webserver/index.html")));
+                       Assertion.Assert ("#7", !p.IsBypassed (new Uri ("http://webserver.com/index.html")));
+
+                       p = new WebProxy ("http://proxy.contoso.com", false);
+                       Assertion.Assert ("#11", !p.IsBypassed (new Uri ("http://www.google.com")));
+                       Assertion.Assert ("#12: lamespec of ms.net", p.IsBypassed (new Uri ("http://localhost/index.html")));
+                       Assertion.Assert ("#13: lamespec of ms.net", p.IsBypassed (new Uri ("http://localhost:8080/index.html")));
+                       Assertion.Assert ("#14: lamespec of ms.net", p.IsBypassed (new Uri ("http://loopback:8080/index.html")));
+                       Assertion.Assert ("#15: lamespec of ms.net", p.IsBypassed (new Uri ("http://127.0.0.01:8080/index.html")));
+                       Assertion.Assert ("#16", !p.IsBypassed (new Uri ("http://webserver/index.html")));
+
+                       p.BypassList = new string [] { "google.com", "contoso.com" };
+                       Assertion.Assert ("#20", p.IsBypassed (new Uri ("http://www.google.com")));
+                       Assertion.Assert ("#21", p.IsBypassed (new Uri ("http://www.GOOGLE.com")));
+                       Assertion.Assert ("#22", p.IsBypassed (new Uri ("http://www.contoso.com:8080/foo/bar/index.html")));
+                       Assertion.Assert ("#23", !p.IsBypassed (new Uri ("http://www.contoso2.com:8080/foo/bar/index.html")));
+                       Assertion.Assert ("#24", !p.IsBypassed (new Uri ("http://www.foo.com:8080/contoso.com.html")));
+
+                       p.BypassList = new string [] { "https" };
+                       Assertion.Assert ("#30", !p.IsBypassed (new Uri ("http://www.google.com")));
+                       Assertion.Assert ("#31", p.IsBypassed (new Uri ("https://www.google.com")));
+               }
+
+               [Test]
+               public void IsByPassed_Host_Null ()
+               {
+                       WebProxy p = new WebProxy ("http://proxy.contoso.com", true);
+                       try {
+                               p.IsBypassed (null);
+                               Assertion.Fail ("#A1");
+#if NET_2_0
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
+                               Assert.IsNotNull (ex.Message, "#A3");
+                               Assert.IsNotNull (ex.ParamName, "#A4");
+                               Assert.AreEqual ("host", ex.ParamName, "#A5");
+                               Assert.IsNull (ex.InnerException, "#A6");
+                       }
+#else
+                       } catch (NullReferenceException) {
+                       }
+#endif
+
+                       p = new WebProxy ((Uri) null);
+                       try {
+                               p.IsBypassed (null);
+                               Assertion.Fail ("#B1");
+#if NET_2_0
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
+                               Assert.IsNotNull (ex.Message, "#B3");
+                               Assert.IsNotNull (ex.ParamName, "#B4");
+                               Assert.AreEqual ("host", ex.ParamName, "#B5");
+                               Assert.IsNull (ex.InnerException, "#B6");
+                       }
+#else
+                       } catch (NullReferenceException) {
+                       }
+#endif
+               }
+
+
+               [Test]
+               public void GetObjectData ()
+               {
+                       SerializationInfo si = new SerializationInfo (typeof (WebHeaderCollection),
+                               new FormatterConverter ());
+
+                       WebProxy proxy = new WebProxy ("proxy.ximian.com");
+                       ((ISerializable) proxy).GetObjectData (si, new StreamingContext ());
+#if NET_2_0
+                       Assert.AreEqual (4, si.MemberCount, "#A1");
+#else
+                       Assert.AreEqual (3, si.MemberCount, "#A1");
+#endif
+                       int i = 0;
+                       foreach (SerializationEntry entry in si) {
+                               Assert.IsNotNull (entry.Name, "#A2:" + i);
+                               Assert.IsNotNull (entry.ObjectType, "#A3:" + i);
+
+                               switch (i) {
+                               case 0:
+                                       Assert.AreEqual ("_BypassOnLocal", entry.Name, "#A4:" + i);
+                                       Assert.AreEqual (typeof (bool), entry.ObjectType, "#A5:" + i);
+                                       Assert.IsNotNull (entry.Value, "#A6:" + i);
+                                       Assert.AreEqual (false, entry.Value, "#A7:" + i);
+                                       break;
+                               case 1:
+                                       Assert.AreEqual ("_ProxyAddress", entry.Name, "#A4:" + i);
+                                       Assert.AreEqual (typeof (Uri), entry.ObjectType, "#A5:" + i);
+                                       Assert.IsNotNull (entry.Value, "#A6:" + i);
+                                       break;
+                               case 2:
+                                       Assert.AreEqual ("_BypassList", entry.Name, "#A4:" + i);
+                                       Assert.AreEqual (typeof (object), entry.ObjectType, "#A5:" + i);
+                                       Assert.IsNull (entry.Value, "#A6:" + i);
+                                       break;
+#if NET_2_0
+                               case 3:
+                                       Assert.AreEqual ("_UseDefaultCredentials", entry.Name, "#A4:" + i);
+                                       Assert.AreEqual (typeof (bool), entry.ObjectType, "#A5:" + i);
+                                       Assert.IsNotNull (entry.Value, "#A6:" + i);
+                                       Assert.AreEqual (false, entry.Value, "#A7:" + i);
+                                       break;
+#endif
+                               }
+                               i++;
+                       }
+               }
+       }
+}