2 // CookieCollectionTest.cs - NUnit Test Cases for System.Net.CookieCollection
\r
5 // Lawrence Pit (loz@cable.a2000.nl)
\r
6 // Martin Willemoes Hansen (mwh@sysrq.dk)
\r
8 // (C) 2003 Martin Willemoes Hansen
\r
11 using NUnit.Framework;
\r
14 using System.Collections;
\r
16 namespace MonoTests.System.Net
\r
20 public class CookieCollectionTest
\r
22 CookieCollection col;
\r
25 public void GetReady ()
\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
34 public void Count ()
\r
36 Assert.AreEqual (col.Count, 3, "#1");
\r
40 public void Indexer ()
\r
46 } catch (ArgumentOutOfRangeException) {
\r
49 c = col [col.Count];
\r
51 } catch (ArgumentOutOfRangeException) {
\r
54 Assert.AreEqual (c.Name, "name1", "#3");
\r
56 Assert.AreEqual (c.Name, "name2", "#4");
\r
66 } catch (ArgumentNullException) {
\r
69 // in the microsoft implementation this will fail,
\r
70 // so we'll have to fail to.
\r
74 } catch (Exception) {
\r
76 Assert.AreEqual (col.Count, 3, "#3");
\r
78 col.Add (new Cookie("name1", "value1"));
\r
79 Assert.AreEqual (col.Count, 3, "#4");
\r
81 CookieCollection col2 = new CookieCollection();
\r
82 Cookie c4 = new Cookie("name4", "value4");
\r
83 Cookie c5 = new Cookie("name5", "value5");
\r
87 Assert.AreEqual (col.Count, 5, "#5");
\r
88 Assert.AreEqual (col ["NAME4"], c4, "#6");
\r
89 Assert.AreEqual (col [4], c5, "#7");
\r
93 public void CopyTo ()
\r
95 Array a = Array.CreateInstance (typeof (Cookie), 3);
\r
97 Assert.AreEqual (a.GetValue (0), col [0], "#1");
\r
98 Assert.AreEqual (a.GetValue (1), col [1], "#2");
\r
99 Assert.AreEqual (a.GetValue (2), col [2], "#3");
\r
103 public void Enumerator ()
\r
105 IEnumerator enumerator = col.GetEnumerator ();
\r
106 enumerator.MoveNext ();
\r
107 Cookie c = (Cookie) enumerator.Current;
\r
108 Assert.AreEqual (c, col [0], "#1");
\r
109 col.Add (new Cookie ("name6", "value6"));
\r
111 enumerator.MoveNext ();
\r
112 Assert.Fail ("#2");
\r
113 } catch (InvalidOperationException) {
\r