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.
35 using System.Web.UI.WebControls;
36 using NUnit.Framework;
37 using System.Collections;
39 namespace MonoTests.System.Web.UI.WebControls
42 public class WizardStepCollectionTest
46 public void WizardStepCollection_DefaultProperty ()
48 Wizard w = new Wizard();
49 Assert.AreEqual (typeof (WizardStepCollection), w.WizardSteps.GetType (), "WizardStepCollection");
50 Assert.AreEqual (0,w.WizardSteps.Count, "Count");
51 Assert.AreEqual (false, w.WizardSteps.IsReadOnly, "IsReadOnly");
52 Assert.AreEqual (false, w.WizardSteps.IsSynchronized, "IsSynchronized");
53 Assert.AreEqual (w.WizardSteps, w.WizardSteps.SyncRoot, "SyncRoot");
57 public void WizardStepCollection_Add ()
59 Wizard w = new Wizard ();
60 WizardStep step1 = new WizardStep ();
62 w.WizardSteps.Add (step1);
65 Assert.Fail (e.Message);
67 Assert.AreEqual (1, w.WizardSteps.Count, "Add step fail");
71 public void WizardStepCollection_AddAt ()
73 Wizard w = new Wizard ();
74 WizardStep step1 = new WizardStep ();
75 WizardStep step2 = new WizardStep ();
78 w.WizardSteps.Add (step1);
79 w.WizardSteps.AddAt (0, step2);
82 Assert.Fail (e.Message);
84 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
85 Assert.AreEqual (step2, w.WizardSteps[0], "Step index fail");
88 public void WizardStepCollection_Clear ()
90 Wizard w = new Wizard ();
91 WizardStep step1 = new WizardStep ();
92 WizardStep step2 = new WizardStep ();
95 w.WizardSteps.Add (step1);
96 w.WizardSteps.Add (step2);
99 Assert.Fail (e.Message);
101 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
102 w.WizardSteps.Clear ();
103 Assert.AreEqual (0, w.WizardSteps.Count, "Step clear fail");
107 public void WizardStepCollection_Contains ()
109 Wizard w = new Wizard ();
110 WizardStep step1 = new WizardStep ();
111 WizardStep step2 = new WizardStep ();
114 w.WizardSteps.Add (step1);
116 catch (Exception e) {
117 Assert.Fail (e.Message);
119 Assert.AreEqual (1, w.WizardSteps.Count, "Step count fail");
120 Assert.AreEqual (true, w.WizardSteps.Contains (step1), "Step contains fail#1");
121 Assert.AreEqual (false, w.WizardSteps.Contains (step2), "Step contains fail#2");
125 public void WizardStepCollection_CopyTo ()
127 Wizard w = new Wizard ();
128 WizardStep step1 = new WizardStep ();
129 WizardStep step2 = new WizardStep ();
133 w.WizardSteps.Add (step1);
134 w.WizardSteps.Add (step2);
136 catch (Exception e) {
137 Assert.Fail (e.Message);
139 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
140 WizardStep[] steps = new WizardStep [w.WizardSteps.Count] ;
141 w.WizardSteps.CopyTo (steps, 0);
142 Assert.AreEqual (2, steps.GetLength (0), "Copyto elements count");
143 Assert.AreEqual (step1, steps[0], "Copyto elements equal#1");
144 Assert.AreEqual (step2, steps[1], "Copyto elements equal#2");
148 public void WizardStepCollection_GetEnumerator ()
150 Wizard w = new Wizard ();
151 WizardStep step1 = new WizardStep ();
152 WizardStep step2 = new WizardStep ();
156 w.WizardSteps.Add (step1);
157 w.WizardSteps.Add (step2);
159 catch (Exception e) {
160 Assert.Fail (e.Message);
162 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
163 IEnumerator numerator = w.WizardSteps.GetEnumerator ();
165 numerator.MoveNext ();
166 Assert.AreEqual (step1, numerator.Current, "Enumerator item value#1");
167 numerator.MoveNext ();
168 Assert.AreEqual (step2, numerator.Current, "Enumerator item value#2");
172 public void WizardStepCollection_Insert ()
174 Wizard w = new Wizard ();
175 WizardStep step1 = new WizardStep ();
176 WizardStep step2 = new WizardStep ();
179 w.WizardSteps.Add (step1);
180 w.WizardSteps.Insert (0, step2);
182 catch (Exception e) {
183 Assert.Fail (e.Message);
185 Assert.AreEqual (2, w.WizardSteps.Count, "Step count fail");
186 Assert.AreEqual (step2, w.WizardSteps[0], "Step index fail");
190 public void WizardStepCollection_Remove ()
192 Wizard w = new Wizard ();
193 WizardStep step1 = new WizardStep ();
194 WizardStep step2 = new WizardStep ();
197 w.WizardSteps.Add (step1);
198 w.WizardSteps.Add (step2);
200 catch (Exception e) {
201 Assert.Fail (e.Message);
203 Assert.AreEqual (2, w.WizardSteps.Count, "Step count before remove fail");
205 w.WizardSteps.Remove (step1);
206 w.WizardSteps.Remove (step2);
208 catch (Exception e) {
209 Assert.Fail (e.Message);
211 Assert.AreEqual (0, w.WizardSteps.Count, "Step count after remove fail");
215 public void WizardStepCollection_RemoveAt ()
217 Wizard w = new Wizard ();
218 WizardStep step1 = new WizardStep ();
219 WizardStep step2 = new WizardStep ();
222 w.WizardSteps.Add (step1);
223 w.WizardSteps.Add (step2);
225 catch (Exception e) {
226 Assert.Fail (e.Message);
228 Assert.AreEqual (2, w.WizardSteps.Count, "Step count before removeat fail");
230 w.WizardSteps.RemoveAt (0);
233 catch (Exception e) {
234 Assert.Fail (e.Message);
236 Assert.AreEqual (1, w.WizardSteps.Count, "Step count after removeat fail");
237 Assert.AreEqual (step2, w.WizardSteps[0], "Item value after remove");