2 // CookieCollectionTest.cs - NUnit Test Cases for System.Net.CookieCollection
\r
5 // Lawrence Pit (loz@cable.a2000.nl)
\r
8 using NUnit.Framework;
\r
11 using System.Collections;
\r
13 namespace MonoTests.System.Net
\r
16 public class CookieCollectionTest : TestCase
\r
18 CookieCollection col;
\r
20 public CookieCollectionTest () :
\r
21 base ("[MonoTests.System.Net.CookieCollectionTest]") {}
\r
23 public CookieCollectionTest (string name) : base (name) {}
\r
25 protected override void SetUp ()
\r
27 col = new CookieCollection ();
\r
28 col.Add (new Cookie ("name1", "value1"));
\r
29 col.Add (new Cookie ("name2", "value2", "path2"));
\r
30 col.Add (new Cookie ("name3", "value3", "path3", "domain3"));
\r
33 protected override void TearDown () {}
\r
35 public static ITest Suite
\r
38 return new TestSuite (typeof (CookieCollectionTest));
\r
42 public void TestCount ()
\r
44 AssertEquals ("#1", col.Count, 3);
\r
47 public void TestIndexer ()
\r
53 } catch (ArgumentOutOfRangeException) {
\r
56 c = col [col.Count];
\r
58 } catch (ArgumentOutOfRangeException) {
\r
61 AssertEquals ("#3", c.Name, "name1");
\r
63 AssertEquals ("#4", c.Name, "name2");
\r
66 public void TestAdd ()
\r
72 } catch (ArgumentNullException) {
\r
75 // in the microsoft implementation this will fail,
\r
76 // so we'll have to fail to.
\r
80 } catch (Exception) {
\r
82 AssertEquals ("#3", col.Count, 3);
\r
84 col.Add (new Cookie("name1", "value1"));
\r
85 AssertEquals ("#4", col.Count, 3);
\r
87 CookieCollection col2 = new CookieCollection();
\r
88 Cookie c4 = new Cookie("name4", "value4");
\r
89 Cookie c5 = new Cookie("name5", "value5");
\r
93 AssertEquals ("#5", col.Count, 5);
\r
94 AssertEquals ("#6", col ["NAME4"], c4);
\r
95 AssertEquals ("#7", col [4], c5);
\r
98 public void TestCopyTo ()
\r
100 Array a = Array.CreateInstance (typeof (Cookie), 3);
\r
102 AssertEquals ("#1", a.GetValue (0), col [0]);
\r
103 AssertEquals ("#2", a.GetValue (1), col [1]);
\r
104 AssertEquals ("#3", a.GetValue (2), col [2]);
\r
107 public void TestEnumerator ()
\r
109 IEnumerator enumerator = col.GetEnumerator ();
\r
110 enumerator.MoveNext ();
\r
111 Cookie c = (Cookie) enumerator.Current;
\r
112 AssertEquals ("#1", c, col [0]);
\r
113 col.Add (new Cookie ("name6", "value6"));
\r
115 enumerator.MoveNext ();
\r
117 } catch (InvalidOperationException) {
\r