(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System / Test / System.Net / CookieCollectionTest.cs
blobd94c2164115085938dbb37c9dc721a426050afb7
1 //
2 // CookieCollectionTest.cs - NUnit Test Cases for System.Net.CookieCollection
3 //
4 // Authors:
5 // Lawrence Pit (loz@cable.a2000.nl)
6 // Martin Willemoes Hansen (mwh@sysrq.dk)
7 //
8 // (C) 2003 Martin Willemoes Hansen
9 //
11 using NUnit.Framework;
12 using System;
13 using System.Net;
14 using System.Collections;
16 namespace MonoTests.System.Net
19 [TestFixture]
20 public class CookieCollectionTest
22 CookieCollection col;
24 [SetUp]
25 public void GetReady ()
27 col = new CookieCollection ();
28 col.Add (new Cookie ("name1", "value1"));
29 col.Add (new Cookie ("name2", "value2", "path2"));
30 col.Add (new Cookie ("name3", "value3", "path3", "domain3"));
33 [Test]
34 public void Count ()
36 Assertion.AssertEquals ("#1", col.Count, 3);
39 [Test]
40 public void Indexer ()
42 Cookie c = null;
43 try {
44 c = col [-1];
45 Assertion.Fail ("#1");
46 } catch (ArgumentOutOfRangeException) {
48 try {
49 c = col [col.Count];
50 Assertion.Fail ("#2");
51 } catch (ArgumentOutOfRangeException) {
53 c = col ["name1"];
54 Assertion.AssertEquals ("#3", c.Name, "name1");
55 c = col ["NAME2"];
56 Assertion.AssertEquals ("#4", c.Name, "name2");
59 [Test]
60 public void Add ()
62 try {
63 Cookie c = null;
64 col.Add (c);
65 Assertion.Fail ("#1");
66 } catch (ArgumentNullException) {
69 // in the microsoft implementation this will fail,
70 // so we'll have to fail to.
71 try {
72 col.Add (col);
73 Assertion.Fail ("#2");
74 } catch (Exception) {
76 Assertion.AssertEquals ("#3", col.Count, 3);
78 col.Add (new Cookie("name1", "value1"));
79 Assertion.AssertEquals ("#4", col.Count, 3);
81 CookieCollection col2 = new CookieCollection();
82 Cookie c4 = new Cookie("name4", "value4");
83 Cookie c5 = new Cookie("name5", "value5");
84 col2.Add (c4);
85 col2.Add (c5);
86 col.Add (col2);
87 Assertion.AssertEquals ("#5", col.Count, 5);
88 Assertion.AssertEquals ("#6", col ["NAME4"], c4);
89 Assertion.AssertEquals ("#7", col [4], c5);
92 [Test]
93 public void CopyTo ()
95 Array a = Array.CreateInstance (typeof (Cookie), 3);
96 col.CopyTo (a, 0);
97 Assertion.AssertEquals ("#1", a.GetValue (0), col [0]);
98 Assertion.AssertEquals ("#2", a.GetValue (1), col [1]);
99 Assertion.AssertEquals ("#3", a.GetValue (2), col [2]);
102 [Test]
103 public void Enumerator ()
105 IEnumerator enumerator = col.GetEnumerator ();
106 enumerator.MoveNext ();
107 Cookie c = (Cookie) enumerator.Current;
108 Assertion.AssertEquals ("#1", c, col [0]);
109 col.Add (new Cookie ("name6", "value6"));
110 try {
111 enumerator.MoveNext ();
112 Assertion.Fail ("#2");
113 } catch (InvalidOperationException) {