2008-01-26 Daniel Nauck <dna@mono-project.de>
authorDaniel Nauck <dna@mono-project.de>
Sat, 26 Jan 2008 15:54:20 +0000 (15:54 -0000)
committerDaniel Nauck <dna@mono-project.de>
Sat, 26 Jan 2008 15:54:20 +0000 (15:54 -0000)
* CookieTest.cs: added tests for Cookie.ToString (), see bug #316017,
fixed line endings

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

mcs/class/System/Test/System.Net/ChangeLog
mcs/class/System/Test/System.Net/CookieTest.cs

index 1b74fc6d94e454180311c74d48d7fc5d094ae427..c6a5fcc9ebcd050faf42cec40dc5f5621d5b800d 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-26  Daniel Nauck  <dna@mono-project.de>
+
+       * CookieTest.cs: added tests for Cookie.ToString (), see bug #316017,
+       fixed line endings
+
 2008-01-17  Zoltan Varga  <vargaz@gmail.com>
 
        * HttpWebRequestTest.cs: Disable #353495 since it fails on the 2.0 profile.
index acdc35a82f4edee28f6e00e7298bf7ecc32c7ab9..00c58a98c59081edca5b74a47c2c8ea0678a70b8 100644 (file)
-//\r
-// CookieTest.cs - NUnit Test Cases for System.Net.Cookie\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.Net;\r
-\r
-namespace MonoTests.System.Net\r
-{\r
-\r
-[TestFixture]\r
-public class CookieTest\r
-{\r
-       [Test]\r
-        public void PublicFields ()\r
-        {\r
-        }\r
-\r
-       [Test]\r
-        public void Constructors ()\r
-        {\r
-               Cookie c = new Cookie ("somename", null, null, null);\r
-               try {\r
-                       c = new Cookie (null, null, null, null);\r
-                       Assertion.Fail ("#1: Name cannot be null");\r
-               } catch (CookieException) {\r
-               }\r
-        }\r
-        \r
-       [Test]\r
-        public void Name ()         \r
-        {\r
-               Cookie c = new Cookie ("SomeName", "SomeValue");\r
-               Assertion.AssertEquals ("#1", c.Name, "SomeName");\r
-               try {\r
-                       c.Name = null;\r
-                       Assertion.Fail ("#2a");\r
-               } catch (CookieException) {\r
-                       Assertion.AssertEquals ("#2b", "SomeName", c.Name);\r
-               }\r
-               try {\r
-                       c.Name = "";\r
-                       Assertion.Fail ("#2c");\r
-               } catch (CookieException) {\r
-                       Assertion.AssertEquals ("#2d", "SomeName", c.Name);                     \r
-               }\r
-               try {\r
-                       c.Name = " ";\r
-                       Assertion.Fail ("#2e");                 \r
-               } catch (CookieException) {\r
-                       // bah! this fails, yet the name is changed.. \r
-                       // inconsistent with previous test\r
-                       Assertion.AssertEquals ("#2f", String.Empty, c.Name);                   \r
-               }\r
-               try {\r
-                       c.Name = "xxx\r\n";\r
-                       Assertion.Fail ("#2g");                 \r
-               } catch (CookieException) {\r
-                       Assertion.AssertEquals ("#2h", String.Empty, c.Name);                   \r
-               }               \r
-               try {\r
-                       c.Name = "xxx" + (char) 0x80;\r
-               } catch (CookieException) {\r
-                       Assertion.Fail ("#2i");                 \r
-               }                               \r
-               try {\r
-                       c.Name = "$omeName";\r
-                       Assertion.Fail ("#3a: Name cannot start with '$' character");\r
-               } catch (CookieException) {\r
-                       Assertion.AssertEquals ("#3b", String.Empty, c.Name);\r
-               }\r
-               c.Name = "SomeName$";\r
-               Assertion.AssertEquals ("#4", c.Name, "SomeName$");\r
-               try {\r
-                       c.Name = "Some=Name";\r
-                       Assertion.Fail ("#5a: Name cannot contain '=' character");\r
-               } catch (CookieException) {\r
-                       Assertion.AssertEquals ("#5b", String.Empty, c.Name);\r
-               }               \r
-               c.Name = "domain";\r
-               Assertion.AssertEquals ("#6", c.Name, "domain");\r
-       }\r
-       \r
-       [Test]\r
-       public void Value ()\r
-       {\r
-               // LAMESPEC: According to .Net specs the Value property should not accept \r
-               // the semicolon and comma characters, yet it does\r
-               /*\r
-               Cookie c = new Cookie("SomeName", "SomeValue");\r
-               try {\r
-                       c.Value = "Some;Value";\r
-                       Assertion.Fail ("#1: semicolon should not be accepted");\r
-               } catch (CookieException) {\r
-               }\r
-               try {\r
-                       c.Value = "Some,Value";\r
-                       Assertion.Fail ("#2: comma should not be accepted");\r
-               } catch (CookieException) {\r
-               }\r
-               c.Value = "Some\tValue";\r
-               Assertion.AssertEquals ("#3", c.Value, "Some\tValue");\r
-               */\r
-       }\r
-       \r
-       [Test]\r
-       public void Port ()\r
-       {\r
-               Cookie c = new Cookie ("SomeName", "SomeValue");\r
-               try {\r
-                       c.Port = "123";\r
-                       Assertion.Fail ("#1: port must start and end with double quotes");\r
-               } catch (CookieException) {                     \r
-               }\r
-               try {\r
-                       c.Port = "\"123\"";\r
-               } catch (CookieException) {                     \r
-                       Assertion.Fail ("#2");\r
-               }\r
-               try {\r
-                       c.Port = "\"123;124\"";\r
-                       Assertion.Fail ("#3");\r
-               } catch (CookieException) {                                     \r
-               }\r
-               try {\r
-                       c.Port = "\"123,123,124\"";\r
-               } catch (CookieException) {                     \r
-                       Assertion.Fail ("#4");\r
-               }\r
-               try {\r
-                       c.Port = "\"123,124\"";\r
-               } catch (CookieException) {                     \r
-                       Assertion.Fail ("#5");\r
-               }\r
-       }\r
-\r
-       [Test]\r
-        public void Equals ()\r
-        {\r
-               Cookie c1 = new Cookie ("NAME", "VALUE", "PATH", "DOMAIN");\r
-               Cookie c2 = new Cookie ("name", "value", "path", "domain");\r
-               Assertion.Assert("#1", !c1.Equals (c2));\r
-               c2.Value = "VALUE";\r
-               c2.Path = "PATH";\r
-               Assertion.Assert("#2", c1.Equals (c2));\r
-               c2.Version = 1;\r
-               Assertion.Assert("#3", !c1.Equals (c2));\r
-        }\r
-}\r
-\r
-}\r
-\r
+//
+// CookieTest.cs - NUnit Test Cases for System.Net.Cookie
+//
+// Authors:
+//     Lawrence Pit (loz@cable.a2000.nl)
+//     Martin Willemoes Hansen (mwh@sysrq.dk)
+//     Daniel Nauck    (dna(at)mono-project(dot)de)
+//
+// (C) 2003 Martin Willemoes Hansen
+//
+
+using NUnit.Framework;
+using System;
+using System.Net;
+
+namespace MonoTests.System.Net
+{
+
+       [TestFixture]
+       public class CookieTest
+       {
+               [Test]
+               public void PublicFields ()
+               {
+               }
+
+               [Test]
+               public void Constructors ()
+               {
+                       Cookie c = new Cookie ("somename", null, null, null);
+                       try
+                       {
+                               c = new Cookie (null, null, null, null);
+                               Assertion.Fail ("#1: Name cannot be null");
+                       }
+                       catch (CookieException)
+                       {
+                       }
+               }
+
+               [Test]
+               public void Name ()
+               {
+                       Cookie c = new Cookie ("SomeName", "SomeValue");
+                       Assertion.AssertEquals ("#1", c.Name, "SomeName");
+                       try
+                       {
+                               c.Name = null;
+                               Assertion.Fail ("#2a");
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.AssertEquals ("#2b", "SomeName", c.Name);
+                       }
+                       try
+                       {
+                               c.Name = "";
+                               Assertion.Fail ("#2c");
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.AssertEquals ("#2d", "SomeName", c.Name);
+                       }
+                       try
+                       {
+                               c.Name = " ";
+                               Assertion.Fail ("#2e");
+                       }
+                       catch (CookieException)
+                       {
+                               // bah! this fails, yet the name is changed.. 
+                               // inconsistent with previous test
+                               Assertion.AssertEquals ("#2f", String.Empty, c.Name);
+                       }
+                       try
+                       {
+                               c.Name = "xxx\r\n";
+                               Assertion.Fail ("#2g");
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.AssertEquals ("#2h", String.Empty, c.Name);
+                       }
+                       try
+                       {
+                               c.Name = "xxx" + (char)0x80;
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.Fail ("#2i");
+                       }
+                       try
+                       {
+                               c.Name = "$omeName";
+                               Assertion.Fail ("#3a: Name cannot start with '$' character");
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.AssertEquals ("#3b", String.Empty, c.Name);
+                       }
+                       c.Name = "SomeName$";
+                       Assertion.AssertEquals ("#4", c.Name, "SomeName$");
+                       try
+                       {
+                               c.Name = "Some=Name";
+                               Assertion.Fail ("#5a: Name cannot contain '=' character");
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.AssertEquals ("#5b", String.Empty, c.Name);
+                       }
+                       c.Name = "domain";
+                       Assertion.AssertEquals ("#6", c.Name, "domain");
+               }
+
+               [Test]
+               public void Value ()
+               {
+                       // LAMESPEC: According to .Net specs the Value property should not accept 
+                       // the semicolon and comma characters, yet it does
+                       /*
+                       Cookie c = new Cookie("SomeName", "SomeValue");
+                       try {
+                               c.Value = "Some;Value";
+                               Assertion.Fail ("#1: semicolon should not be accepted");
+                       } catch (CookieException) {
+                       }
+                       try {
+                               c.Value = "Some,Value";
+                               Assertion.Fail ("#2: comma should not be accepted");
+                       } catch (CookieException) {
+                       }
+                       c.Value = "Some\tValue";
+                       Assertion.AssertEquals ("#3", c.Value, "Some\tValue");
+                       */
+               }
+
+               [Test]
+               public void Port ()
+               {
+                       Cookie c = new Cookie ("SomeName", "SomeValue");
+                       try
+                       {
+                               c.Port = "123";
+                               Assertion.Fail ("#1: port must start and end with double quotes");
+                       }
+                       catch (CookieException)
+                       {
+                       }
+                       try
+                       {
+                               c.Port = "\"123\"";
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.Fail ("#2");
+                       }
+                       try
+                       {
+                               c.Port = "\"123;124\"";
+                               Assertion.Fail ("#3");
+                       }
+                       catch (CookieException)
+                       {
+                       }
+                       try
+                       {
+                               c.Port = "\"123,123,124\"";
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.Fail ("#4");
+                       }
+                       try
+                       {
+                               c.Port = "\"123,124\"";
+                       }
+                       catch (CookieException)
+                       {
+                               Assertion.Fail ("#5");
+                       }
+               }
+
+               [Test]
+               public void Equals ()
+               {
+                       Cookie c1 = new Cookie ("NAME", "VALUE", "PATH", "DOMAIN");
+                       Cookie c2 = new Cookie ("name", "value", "path", "domain");
+                       Assertion.Assert ("#1", !c1.Equals (c2));
+                       c2.Value = "VALUE";
+                       c2.Path = "PATH";
+                       Assertion.Assert ("#2", c1.Equals (c2));
+                       c2.Version = 1;
+                       Assertion.Assert ("#3", !c1.Equals (c2));
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ToStringTest ()
+               {
+                       Cookie c1 = new Cookie ("NAME", "VALUE", "/", "example.com");
+                       Assert.AreEqual ("NAME=VALUE", c1.ToString (), "#A1");
+
+                       Cookie c2 = new Cookie ();
+                       Assert.AreEqual (string.Empty, c2.ToString (), "#A2");
+
+                       Cookie c3 = new Cookie("NAME", "VALUE");
+                       Assert.AreEqual ("NAME=VALUE", c3.ToString (), "#A3");
+
+                       Cookie c4 = new Cookie ("NAME", "VALUE", "/", "example.com");
+                       c4.Version = 1;
+                       Assert.AreEqual ("$Version=1; NAME=VALUE; $Path=/; $Domain=example.com", c4.ToString (), "#A4");
+
+                       Cookie c5 = new Cookie ("NAME", "VALUE", "/", "example.com");
+                       c5.Port = "\"8080\"";
+                       Assert.AreEqual ("$Version=1; NAME=VALUE; $Path=/; $Domain=example.com; $Port=\"8080\"", c5.ToString (), "#A5");
+
+                       Cookie c6 = new Cookie ("NAME", "VALUE");
+                       c6.Version = 1;
+                       Assert.AreEqual ("$Version=1; NAME=VALUE", c6.ToString (), "#A6");
+               }
+       }
+}
\ No newline at end of file