[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / WizardStepCollectionTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.WizardStepCollectionTest.cs
3 //
4 // Author:
5 //      Yoni Klein (yonik@mainsoft.com)
6 //
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29
30
31 using System;
32 using System.Web;
33 using System.Web.UI;
34 using System.Web.UI.WebControls;
35 using NUnit.Framework;
36 using System.Collections;
37
38 namespace MonoTests.System.Web.UI.WebControls
39 {
40         [TestFixture]
41         public class WizardStepCollectionTest
42         {
43                 
44                 [Test]
45                 public void WizardStepCollection_DefaultProperty ()
46                 {
47                         Wizard w = new Wizard();
48                         Assert.AreEqual (typeof (WizardStepCollection), w.WizardSteps.GetType (), "WizardStepCollection");
49                         Assert.AreEqual (0,w.WizardSteps.Count, "Count");
50                         Assert.AreEqual (false, w.WizardSteps.IsReadOnly, "IsReadOnly");
51                         Assert.AreEqual (false, w.WizardSteps.IsSynchronized, "IsSynchronized");
52                         Assert.AreEqual (w.WizardSteps, w.WizardSteps.SyncRoot, "SyncRoot");
53                 }
54
55                 [Test]
56                 public void WizardStepCollection_Add ()
57                 {
58                         Wizard w = new Wizard ();
59                         WizardStep step1 = new WizardStep ();
60                         try {
61                                 w.WizardSteps.Add (step1);
62                         }
63                         catch (Exception e) {
64                                 Assert.Fail (e.Message);
65                         }
66                         Assert.AreEqual (1, w.WizardSteps.Count, "Add step fail");
67                 }
68
69                 [Test]
70                 public void WizardStepCollection_AddAt ()
71                 {
72                         Wizard w = new Wizard ();
73                         WizardStep step1 = new WizardStep ();
74                         WizardStep step2 = new WizardStep ();
75
76                         try {
77                                 w.WizardSteps.Add (step1);
78                                 w.WizardSteps.AddAt (0, step2);
79                         }
80                         catch (Exception e) {
81                                 Assert.Fail (e.Message);
82                         }
83                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
84                         Assert.AreEqual (step2, w.WizardSteps[0], "Step index fail");
85                 }
86
87                 public void WizardStepCollection_Clear ()
88                 {
89                         Wizard w = new Wizard ();
90                         WizardStep step1 = new WizardStep ();
91                         WizardStep step2 = new WizardStep ();
92
93                         try {
94                                 w.WizardSteps.Add (step1);
95                                 w.WizardSteps.Add (step2);
96                         }
97                         catch (Exception e) {
98                                 Assert.Fail (e.Message);
99                         }
100                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
101                         w.WizardSteps.Clear ();
102                         Assert.AreEqual (0, w.WizardSteps.Count, "Step clear fail");
103                 }
104
105                 [Test]
106                 public void WizardStepCollection_Contains ()
107                 {
108                         Wizard w = new Wizard ();
109                         WizardStep step1 = new WizardStep ();
110                         WizardStep step2 = new WizardStep ();
111
112                         try {
113                                 w.WizardSteps.Add (step1);
114                         }
115                         catch (Exception e) {
116                                 Assert.Fail (e.Message);
117                         }
118                         Assert.AreEqual (1, w.WizardSteps.Count, "Step count fail");
119                         Assert.AreEqual (true, w.WizardSteps.Contains (step1), "Step contains fail#1");
120                         Assert.AreEqual (false, w.WizardSteps.Contains (step2), "Step contains fail#2");
121                 }
122
123                 [Test]
124                 public void WizardStepCollection_CopyTo ()
125                 {
126                         Wizard w = new Wizard ();
127                         WizardStep step1 = new WizardStep ();
128                         WizardStep step2 = new WizardStep ();
129                         
130
131                         try {
132                                 w.WizardSteps.Add (step1);
133                                 w.WizardSteps.Add (step2);
134                         }
135                         catch (Exception e) {
136                                 Assert.Fail (e.Message);
137                         }
138                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
139                         WizardStep[] steps = new WizardStep [w.WizardSteps.Count] ;
140                         w.WizardSteps.CopyTo (steps, 0);
141                         Assert.AreEqual (2, steps.GetLength (0), "Copyto elements count");
142                         Assert.AreEqual (step1, steps[0], "Copyto elements equal#1");
143                         Assert.AreEqual (step2, steps[1], "Copyto elements equal#2");
144                 }
145
146                 [Test]
147                 public void WizardStepCollection_GetEnumerator ()
148                 {
149                         Wizard w = new Wizard ();
150                         WizardStep step1 = new WizardStep ();
151                         WizardStep step2 = new WizardStep ();
152
153
154                         try {
155                                 w.WizardSteps.Add (step1);
156                                 w.WizardSteps.Add (step2);
157                         }
158                         catch (Exception e) {
159                                 Assert.Fail (e.Message);
160                         }
161                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
162                         IEnumerator numerator = w.WizardSteps.GetEnumerator ();
163                         numerator.Reset();
164                         numerator.MoveNext ();
165                         Assert.AreEqual (step1, numerator.Current, "Enumerator item value#1");
166                         numerator.MoveNext ();
167                         Assert.AreEqual (step2, numerator.Current, "Enumerator item value#2");
168                 }
169
170                 [Test]
171                 public void WizardStepCollection_Insert ()
172                 {
173                         Wizard w = new Wizard ();
174                         WizardStep step1 = new WizardStep ();
175                         WizardStep step2 = new WizardStep ();
176
177                         try {
178                                 w.WizardSteps.Add (step1);
179                                 w.WizardSteps.Insert (0, step2);
180                         }
181                         catch (Exception e) {
182                                 Assert.Fail (e.Message);
183                         }
184                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
185                         Assert.AreEqual (step2, w.WizardSteps[0], "Step index fail");
186                 }
187
188                 [Test]
189                 public void WizardStepCollection_Remove ()
190                 {
191                         Wizard w = new Wizard ();
192                         WizardStep step1 = new WizardStep ();
193                         WizardStep step2 = new WizardStep ();
194
195                         try {
196                                 w.WizardSteps.Add (step1);
197                                 w.WizardSteps.Add (step2);
198                         }
199                         catch (Exception e) {
200                                 Assert.Fail (e.Message);
201                         }
202                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count before remove fail");
203                         try {
204                                 w.WizardSteps.Remove (step1);
205                                 w.WizardSteps.Remove (step2);
206                         }
207                         catch (Exception e) {
208                                 Assert.Fail (e.Message);
209                         }
210                         Assert.AreEqual (0, w.WizardSteps.Count, "Step count after remove fail");
211                 }
212
213                 [Test]
214                 public void WizardStepCollection_RemoveAt ()
215                 {
216                         Wizard w = new Wizard ();
217                         WizardStep step1 = new WizardStep ();
218                         WizardStep step2 = new WizardStep ();
219
220                         try {
221                                 w.WizardSteps.Add (step1);
222                                 w.WizardSteps.Add (step2);
223                         }
224                         catch (Exception e) {
225                                 Assert.Fail (e.Message);
226                         }
227                         Assert.AreEqual (2, w.WizardSteps.Count, "Step count before removeat fail");
228                         try {
229                                 w.WizardSteps.RemoveAt (0);
230                                 
231                         }
232                         catch (Exception e) {
233                                 Assert.Fail (e.Message);
234                         }
235                         Assert.AreEqual (1, w.WizardSteps.Count, "Step count after removeat fail");
236                         Assert.AreEqual (step2, w.WizardSteps[0], "Item value after remove");
237                 }
238         }
239 }