2009-06-26 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System / Test / System.Net / WebHeaderCollectionTest.cs
index 8d335903796e9725dfb555cf8d014169a5296086..384ba0eaf3e01e13eacee74ea42959b519c989fc 100644 (file)
@@ -40,44 +40,44 @@ namespace MonoTests.System.Net
                {
                        try {
                                col.Add (null);
-                               Assertion.Fail ("#1");
+                               Assert.Fail ("#1");
                        } catch (ArgumentNullException) { }
                        try {
                                col.Add ("");
-                               Assertion.Fail ("#2");
+                               Assert.Fail ("#2");
                        } catch (ArgumentException) { }
                        try {
                                col.Add ("  ");
-                               Assertion.Fail ("#3");
+                               Assert.Fail ("#3");
                        } catch (ArgumentException) { }
                        try {
                                col.Add (":");
-                               Assertion.Fail ("#4");
+                               Assert.Fail ("#4");
                        } catch (ArgumentException) { }
                        try {
                                col.Add (" : ");
-                               Assertion.Fail ("#5");
+                               Assert.Fail ("#5");
                        } catch (ArgumentException) { }
 
                        try {
                                col.Add ("XHost: foo");
                        } catch (ArgumentException) {
-                               Assertion.Fail ("#7");
+                               Assert.Fail ("#7");
                        }
 
                        // invalid values
                        try {
                                col.Add ("XHost" + ((char) 0xa9) + ": foo");
-                               Assertion.Fail ("#8");
+                               Assert.Fail ("#8");
                        } catch (ArgumentException) { }
                        try {
                                col.Add ("XHost: foo" + (char) 0xa9);
                        } catch (ArgumentException) {
-                               Assertion.Fail ("#9");
+                               Assert.Fail ("#9");
                        }
                        try {
                                col.Add ("XHost: foo" + (char) 0x7f);
-                               Assertion.Fail ("#10");
+                               Assert.Fail ("#10");
                        } catch (ArgumentException) {
 
                        }
@@ -85,12 +85,12 @@ namespace MonoTests.System.Net
                        try {
                                col.Add ("XHost", null);
                        } catch (ArgumentException) {
-                               Assertion.Fail ("#11");
+                               Assert.Fail ("#11");
                        }
                        try {
                                col.Add ("XHost:");
                        } catch (ArgumentException) {
-                               Assertion.Fail ("#12");
+                               Assert.Fail ("#12");
                        }
 
                        // restricted
@@ -99,7 +99,7 @@ namespace MonoTests.System.Net
                        try {
                                WebHeaderCollection col2 = new WebHeaderCollection (true);
                                col2.Add ("Host: foo");
-                               Assertion.Fail ("#13: should fail according to spec");
+                               Assert.Fail ("#13: should fail according to spec");
                        } catch (ArgumentException) {}          
                        */
                }
@@ -114,61 +114,61 @@ namespace MonoTests.System.Net
                        w.Add ("Hello", "H3,H4");
 
                        string [] sa = w.GetValues ("Hello");
-                       Assertion.AssertEquals ("#1", 3, sa.Length);
-                       Assertion.AssertEquals ("#2", "H1,H2,H3,H4", w.Get ("Hello"));
+                       Assert.AreEqual (3, sa.Length, "#1");
+                       Assert.AreEqual ("H1, H2,H3,H4", w.Get ("Hello"), "#2");
 
                        w = new WebHeaderCollection ();
                        w.Add ("Accept", "H1");
                        w.Add ("Accept", "H2");
                        w.Add ("Accept", "H3,H4");
-                       Assertion.AssertEquals ("#3a", 3, w.GetValues (0).Length);
-                       Assertion.AssertEquals ("#3b", 4, w.GetValues ("Accept").Length);
-                       Assertion.AssertEquals ("#4", "H1,H2,H3,H4", w.Get ("Accept"));
+                       Assert.AreEqual (3, w.GetValues (0).Length, "#3a");
+                       Assert.AreEqual (4, w.GetValues ("Accept").Length, "#3b");
+                       Assert.AreEqual ("H1, H2,H3,H4", w.Get ("Accept"), "#4");
 
                        w = new WebHeaderCollection ();
                        w.Add ("Allow", "H1");
                        w.Add ("Allow", "H2");
                        w.Add ("Allow", "H3,H4");
                        sa = w.GetValues ("Allow");
-                       Assertion.AssertEquals ("#5", 4, sa.Length);
-                       Assertion.AssertEquals ("#6", "H1,H2,H3,H4", w.Get ("Allow"));
+                       Assert.AreEqual (4, sa.Length, "#5");
+                       Assert.AreEqual ("H1, H2,H3,H4", w.Get ("Allow"), "#6");
 
                        w = new WebHeaderCollection ();
                        w.Add ("AUTHorization", "H1, H2, H3");
                        sa = w.GetValues ("authorization");
-                       Assertion.AssertEquals ("#9", 3, sa.Length);
+                       Assert.AreEqual (3, sa.Length, "#9");
 
                        w = new WebHeaderCollection ();
                        w.Add ("proxy-authenticate", "H1, H2, H3");
                        sa = w.GetValues ("Proxy-Authenticate");
-                       Assertion.AssertEquals ("#9", 3, sa.Length);
+                       Assert.AreEqual (3, sa.Length, "#9");
 
                        w = new WebHeaderCollection ();
                        w.Add ("expect", "H1,\tH2,   H3  ");
                        sa = w.GetValues ("EXPECT");
-                       Assertion.AssertEquals ("#10", 3, sa.Length);
-                       Assertion.AssertEquals ("#11", "H2", sa [1]);
-                       Assertion.AssertEquals ("#12", "H3", sa [2]);
+                       Assert.AreEqual (3, sa.Length, "#10");
+                       Assert.AreEqual ("H2", sa [1], "#11");
+                       Assert.AreEqual ("H3", sa [2], "#12");
 
                        try {
                                w.GetValues (null);
-                               Assertion.Fail ("#13");
+                               Assert.Fail ("#13");
                        } catch (ArgumentNullException) { }
-                       Assertion.AssertEquals ("#14", null, w.GetValues (""));
-                       Assertion.AssertEquals ("#15", null, w.GetValues ("NotExistent"));
+                       Assert.AreEqual (null, w.GetValues (""), "#14");
+                       Assert.AreEqual (null, w.GetValues ("NotExistent"), "#15");
                }
 
                [Test]
                public void Indexers ()
                {
 #if NET_2_0
-               Assertion.AssertEquals ("#1.1", "Value1", ((NameValueCollection)col)[0]);
+               Assert.AreEqual ("Value1", ((NameValueCollection)col)[0], "#1.1");
                //FIXME: test also HttpRequestHeader and HttpResponseHeader
 #else
-                       Assertion.AssertEquals ("#1", "Value1", col [0]);
+                       Assert.AreEqual ("Value1", col [0], "#1");
 #endif
-                       Assertion.AssertEquals ("#2", "Value1", col ["Name1"]);
-                       Assertion.AssertEquals ("#3", "Value1", col ["NAME1"]);
+                       Assert.AreEqual ("Value1", col ["Name1"], "#2");
+                       Assert.AreEqual ("Value1", col ["NAME1"], "#3");
                }
 
                [Test]
@@ -176,7 +176,7 @@ namespace MonoTests.System.Net
                {
                        col.Remove ("Name1");
                        col.Remove ("NameNotExist");
-                       Assertion.AssertEquals ("#1", 1, col.Count);
+                       Assert.AreEqual (1, col.Count, "#1");
 
                        /*
                        // this can only be tested in namespace System.Net
@@ -184,7 +184,7 @@ namespace MonoTests.System.Net
                                WebHeaderCollection col2 = new WebHeaderCollection (true);
                                col2.Add ("Host", "foo");
                                col2.Remove ("Host");
-                               Assertion.Fail ("#2: should fail according to spec");
+                               Assert.Fail ("#2: should fail according to spec");
                        } catch (ArgumentException) {}
                        */
                }
@@ -194,19 +194,19 @@ namespace MonoTests.System.Net
                {
                        col.Add ("Name1", "Value1b");
                        col.Set ("Name1", "\t  X  \t");
-                       Assertion.AssertEquals ("#1", "X", col.Get ("Name1"));
+                       Assert.AreEqual ("X", col.Get ("Name1"), "#1");
                }
 
                [Test]
                public void IsRestricted ()
                {
-                       Assertion.Assert ("#1", !WebHeaderCollection.IsRestricted ("Xhost"));
-                       Assertion.Assert ("#2", WebHeaderCollection.IsRestricted ("Host"));
-                       Assertion.Assert ("#3", WebHeaderCollection.IsRestricted ("HOST"));
-                       Assertion.Assert ("#4", WebHeaderCollection.IsRestricted ("Transfer-Encoding"));
-                       Assertion.Assert ("#5", WebHeaderCollection.IsRestricted ("user-agent"));
-                       Assertion.Assert ("#6", WebHeaderCollection.IsRestricted ("accept"));
-                       Assertion.Assert ("#7", !WebHeaderCollection.IsRestricted ("accept-charset"));
+                       Assert.IsTrue (!WebHeaderCollection.IsRestricted ("Xhost"), "#1");
+                       Assert.IsTrue (WebHeaderCollection.IsRestricted ("Host"), "#2");
+                       Assert.IsTrue (WebHeaderCollection.IsRestricted ("HOST"), "#3");
+                       Assert.IsTrue (WebHeaderCollection.IsRestricted ("Transfer-Encoding"), "#4");
+                       Assert.IsTrue (WebHeaderCollection.IsRestricted ("user-agent"), "#5");
+                       Assert.IsTrue (WebHeaderCollection.IsRestricted ("accept"), "#6");
+                       Assert.IsTrue (!WebHeaderCollection.IsRestricted ("accept-charset"), "#7");
                }
 
                [Test]
@@ -215,7 +215,7 @@ namespace MonoTests.System.Net
                        col.Add ("Name1", "Value1b");
                        col.Add ("Name3", "Value3a\r\n Value3b");
                        col.Add ("Name4", "   Value4   ");
-                       Assertion.AssertEquals ("#1", "Name1: Value1,Value1b\r\nName2: Value2\r\nName3: Value3a\r\n Value3b\r\nName4: Value4\r\n\r\n", col.ToString ());
+                       Assert.AreEqual ("Name1: Value1,Value1b\r\nName2: Value2\r\nName3: Value3a\r\n Value3b\r\nName4: Value4\r\n\r\n", col.ToString (), "#1");
                }
 
                [Test]