2 // Tests for System.Web.UI.WebControls.WizardStepCollectionTest.cs
5 // Yoni Klein (yonik@mainsoft.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
34 using System.Web.UI.WebControls;
35 using NUnit.Framework;
36 using System.Collections;
38 namespace MonoTests.System.Web.UI.WebControls
41 public class WizardStepCollectionTest
45 public void WizardStepCollection_DefaultProperty ()
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");
56 public void WizardStepCollection_Add ()
58 Wizard w = new Wizard ();
59 WizardStep step1 = new WizardStep ();
61 w.WizardSteps.Add (step1);
64 Assert.Fail (e.Message);
66 Assert.AreEqual (1, w.WizardSteps.Count, "Add step fail");
70 public void WizardStepCollection_AddAt ()
72 Wizard w = new Wizard ();
73 WizardStep step1 = new WizardStep ();
74 WizardStep step2 = new WizardStep ();
77 w.WizardSteps.Add (step1);
78 w.WizardSteps.AddAt (0, step2);
81 Assert.Fail (e.Message);
83 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
84 Assert.AreEqual (step2, w.WizardSteps[0], "Step index fail");
87 public void WizardStepCollection_Clear ()
89 Wizard w = new Wizard ();
90 WizardStep step1 = new WizardStep ();
91 WizardStep step2 = new WizardStep ();
94 w.WizardSteps.Add (step1);
95 w.WizardSteps.Add (step2);
98 Assert.Fail (e.Message);
100 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
101 w.WizardSteps.Clear ();
102 Assert.AreEqual (0, w.WizardSteps.Count, "Step clear fail");
106 public void WizardStepCollection_Contains ()
108 Wizard w = new Wizard ();
109 WizardStep step1 = new WizardStep ();
110 WizardStep step2 = new WizardStep ();
113 w.WizardSteps.Add (step1);
115 catch (Exception e) {
116 Assert.Fail (e.Message);
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");
124 public void WizardStepCollection_CopyTo ()
126 Wizard w = new Wizard ();
127 WizardStep step1 = new WizardStep ();
128 WizardStep step2 = new WizardStep ();
132 w.WizardSteps.Add (step1);
133 w.WizardSteps.Add (step2);
135 catch (Exception e) {
136 Assert.Fail (e.Message);
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");
147 public void WizardStepCollection_GetEnumerator ()
149 Wizard w = new Wizard ();
150 WizardStep step1 = new WizardStep ();
151 WizardStep step2 = new WizardStep ();
155 w.WizardSteps.Add (step1);
156 w.WizardSteps.Add (step2);
158 catch (Exception e) {
159 Assert.Fail (e.Message);
161 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
162 IEnumerator numerator = w.WizardSteps.GetEnumerator ();
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");
171 public void WizardStepCollection_Insert ()
173 Wizard w = new Wizard ();
174 WizardStep step1 = new WizardStep ();
175 WizardStep step2 = new WizardStep ();
178 w.WizardSteps.Add (step1);
179 w.WizardSteps.Insert (0, step2);
181 catch (Exception e) {
182 Assert.Fail (e.Message);
184 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
185 Assert.AreEqual (step2, w.WizardSteps[0], "Step index fail");
189 public void WizardStepCollection_Remove ()
191 Wizard w = new Wizard ();
192 WizardStep step1 = new WizardStep ();
193 WizardStep step2 = new WizardStep ();
196 w.WizardSteps.Add (step1);
197 w.WizardSteps.Add (step2);
199 catch (Exception e) {
200 Assert.Fail (e.Message);
202 Assert.AreEqual (2, w.WizardSteps.Count, "Step count before remove fail");
204 w.WizardSteps.Remove (step1);
205 w.WizardSteps.Remove (step2);
207 catch (Exception e) {
208 Assert.Fail (e.Message);
210 Assert.AreEqual (0, w.WizardSteps.Count, "Step count after remove fail");
214 public void WizardStepCollection_RemoveAt ()
216 Wizard w = new Wizard ();
217 WizardStep step1 = new WizardStep ();
218 WizardStep step2 = new WizardStep ();
221 w.WizardSteps.Add (step1);
222 w.WizardSteps.Add (step2);
224 catch (Exception e) {
225 Assert.Fail (e.Message);
227 Assert.AreEqual (2, w.WizardSteps.Count, "Step count before removeat fail");
229 w.WizardSteps.RemoveAt (0);
232 catch (Exception e) {
233 Assert.Fail (e.Message);
235 Assert.AreEqual (1, w.WizardSteps.Count, "Step count after removeat fail");
236 Assert.AreEqual (step2, w.WizardSteps[0], "Item value after remove");