728dbe59540c95a116a4ec1ddeb12a24c53ba587
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / CreateUserWizardTest.cs
1 //
2 // WizardTest.cs - Unit tests for System.Web.UI.WebControls.Wizard
3 //
4 // Author:
5 //      Vladimir Krasnov  <vladimirk@mainsoft.com>
6 //
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 #if NET_2_0
30
31 using System;
32 using System.Drawing;
33 using System.Threading;
34 using System.Collections;
35 using System.IO;
36 using System.Web;
37 using System.Web.UI;
38 using System.Web.UI.WebControls;
39 using System.Web.Security;
40 using System.Text.RegularExpressions;
41 using MonoTests.SystemWeb.Framework;
42 using MonoTests.stand_alone.WebHarness;
43
44 using NUnit.Framework;
45
46 namespace MonoTests.System.Web.UI.WebControls
47 {
48
49         public class TestCreateUserWizard : CreateUserWizard
50         {
51
52                 public string Tag
53                 {
54                         get { return base.TagName; }
55                 }
56
57                 public StateBag StateBag
58                 {
59                         get { return base.ViewState; }
60                 }
61
62                 public string Render ()
63                 {
64                         StringWriter sw = new StringWriter ();
65                         sw.NewLine = "\n";
66                         HtmlTextWriter writer = new HtmlTextWriter (sw);
67                         base.Render (writer);
68                         return writer.InnerWriter.ToString ();
69                 }
70
71                 public Style GetStyle ()
72                 {
73                         return base.CreateControlStyle ();
74                 }
75
76                 public void TrackState ()
77                 {
78                         TrackViewState ();
79                 }
80
81                 public void LoadState (object state)
82                 {
83                         LoadViewState (state);
84                 }
85
86                 public object SaveState ()
87                 {
88                         return SaveViewState ();
89                 }
90
91                 public void SetDesignMode (IDictionary dic)
92                 {
93                         base.SetDesignModeState (dic);
94                 }
95
96                 private bool onBubble;
97
98                 public bool OnBubbleEventCalled
99                 {
100                         get { return onBubble; }
101                         set { onBubble = value; }
102                 }
103
104                 protected override bool OnBubbleEvent (object source, EventArgs e)
105                 {
106                         onBubble = true;
107                         return base.OnBubbleEvent (source, e);
108                 }
109
110                 public bool DoBubbleEvent (object source, EventArgs e)
111                 {
112                         return base.OnBubbleEvent (source, e);
113                 }
114
115                 public void DoEnsureChildControls ()
116                 {
117                         base.EnsureChildControls ();
118                 }
119
120                 public bool DoOnBubbleEvent (EventArgs e)
121                 {
122                         return base.OnBubbleEvent (this, e);
123                 }
124
125                 public int ActiveStepIndex_Before_Init;
126                 public int ActiveStepIndex_After_Init;
127                 protected internal override void OnInit (EventArgs e) {
128                         ActiveStepIndex_Before_Init = ActiveStepIndex;
129                         base.OnInit (e);
130                         ActiveStepIndex_After_Init = ActiveStepIndex;
131                 }
132         }
133
134         [Serializable]
135         [TestFixture]
136         public class CreateUserWizardTest
137         {
138
139                 [TestFixtureTearDown]
140                 public void Unload ()
141                 {
142                         WebTest.Unload ();
143                 }
144
145                 [Test]
146                 [Category ("NunitWeb")]
147 #if TARGET_JVM
148                 [Ignore ("TD #7024")]
149 #endif
150                 public void ActiveStepIndex () {
151                         new WebTest (PageInvoker.CreateOnLoad (ActiveStepIndex_Load)).Run ();
152                 }
153
154                 public static void ActiveStepIndex_Load (Page p) {
155                         TestCreateUserWizard wizard = new TestCreateUserWizard ();
156                         p.Controls.Add (wizard);
157                         Assert.AreEqual (-1, wizard.ActiveStepIndex_Before_Init, "ActiveStepIndex_Before_Init #1");
158                         Assert.AreEqual (0, wizard.ActiveStepIndex_After_Init, "ActiveStepIndex_After_Init #1");
159                         Assert.AreEqual (2, wizard.WizardSteps.Count);
160
161                         wizard = new TestCreateUserWizard ();
162                         wizard.ActiveStepIndex = 1;
163                         p.Controls.Add (wizard);
164                         Assert.AreEqual (1, wizard.ActiveStepIndex_Before_Init, "ActiveStepIndex_Before_Init #2");
165                         Assert.AreEqual (1, wizard.ActiveStepIndex_After_Init, "ActiveStepIndex_After_Init #2");
166                         Assert.AreEqual (2, wizard.WizardSteps.Count);
167                 }
168
169                 [Test]
170                 public void DefaultProperties ()
171                 {
172                         TestCreateUserWizard w = new TestCreateUserWizard ();
173                         Assert.AreEqual (0, w.Attributes.Count, "Attributes.Count");
174                         Assert.AreEqual (0, w.StateBag.Count, "ViewState.Count");
175
176                         Assert.AreEqual ("Security Answer:", w.AnswerLabelText, "AnswerLabelText");
177                         Assert.AreEqual ("Security answer is required.", w.AnswerRequiredErrorMessage, "AnswerRequiredErrorMessage");
178                         Assert.IsFalse (w.AutoGeneratePassword, "AutoGeneratePassword");
179                         Assert.AreEqual ("Your account has been successfully created.", w.CompleteSuccessText, "CompleteSuccessText");
180                         Assert.AreEqual ("The Password and Confirmation Password must match.", w.ConfirmPasswordCompareErrorMessage, "ConfirmPasswordCompareErrorMessage");
181                         Assert.AreEqual ("Confirm Password:", w.ConfirmPasswordLabelText, "ConfirmPasswordLabelText");
182                         Assert.AreEqual ("Confirm Password is required.", w.ConfirmPasswordRequiredErrorMessage, "ConfirmPasswordRequiredErrorMessage");
183                         Assert.AreEqual (string.Empty, w.ContinueButtonImageUrl, "ContinueButtonImageUrl");
184                         Assert.AreEqual ("Continue", w.ContinueButtonText, "ContinueButtonText");
185                         Assert.AreEqual (ButtonType.Button, w.ContinueButtonType, "ContinueButtonType");
186                         Assert.AreEqual (string.Empty, w.ContinueDestinationPageUrl, "ContinueDestinationPageUrl");
187                         Assert.AreEqual (string.Empty, w.CreateUserButtonImageUrl, "CreateUserButtonImageUrl");
188                         Assert.AreEqual ("Create User", w.CreateUserButtonText, "CreateUserButtonText");
189                         Assert.AreEqual (ButtonType.Button, w.CreateUserButtonType, "CreateUserButtonType");
190                         Assert.IsFalse (w.DisableCreatedUser, "DisableCreatedUser");
191                         Assert.AreEqual ("The e-mail address that you entered is already in use. Please enter a different e-mail address.", w.DuplicateEmailErrorMessage, "DuplicateEmailErrorMessage");
192                         Assert.AreEqual ("Please enter a different user name.", w.DuplicateUserNameErrorMessage, "DuplicateUserNameErrorMessage");
193                         Assert.AreEqual (string.Empty, w.EditProfileIconUrl, "EditProfileIconUrl");
194                         Assert.AreEqual (string.Empty, w.EditProfileText, "EditProfileText");
195                         Assert.AreEqual (string.Empty, w.EditProfileUrl, "EditProfileUrl");
196                         Assert.AreEqual ("E-mail:", w.EmailLabelText, "EmailLabelText");
197                         Assert.AreEqual (string.Empty, w.EmailRegularExpression, "EmailRegularExpression");
198                         Assert.AreEqual ("Please enter a different e-mail.", w.EmailRegularExpressionErrorMessage, "EmailRegularExpressionErrorMessage");
199                         Assert.AreEqual ("E-mail is required.", w.EmailRequiredErrorMessage, "EmailRequiredErrorMessage");
200                         Assert.AreEqual (string.Empty, w.HelpPageIconUrl, "HelpPageIconUrl");
201                         Assert.AreEqual (string.Empty, w.HelpPageText, "HelpPageText");
202                         Assert.AreEqual (string.Empty, w.HelpPageUrl, "HelpPageUrl");
203                         Assert.AreEqual (string.Empty, w.InstructionText, "InstructionText");
204                         Assert.AreEqual ("Please enter a different security answer.", w.InvalidAnswerErrorMessage, "InvalidAnswerErrorMessage");
205                         Assert.AreEqual ("Please enter a valid e-mail address.", w.InvalidEmailErrorMessage, "InvalidEmailErrorMessage");
206                         Assert.AreEqual ("Password length minimum: {0}. Non-alphanumeric characters required: {1}.", w.InvalidPasswordErrorMessage, "InvalidPasswordErrorMessage");
207                         Assert.AreEqual ("Please enter a different security question.", w.InvalidQuestionErrorMessage, "InvalidQuestionErrorMessage");
208                         Assert.IsTrue (w.LoginCreatedUser, "LoginCreatedUser");
209                         Assert.AreEqual (string.Empty, w.MembershipProvider, "MembershipProvider");
210                         Assert.AreEqual (string.Empty, w.PasswordHintText, "PasswordHintText");
211                         Assert.AreEqual ("Password:", w.PasswordLabelText, "PasswordLabelText");
212                         Assert.AreEqual (string.Empty, w.PasswordRegularExpression, "PasswordRegularExpression");
213                         Assert.AreEqual ("Please enter a different password.", w.PasswordRegularExpressionErrorMessage, "PasswordRegularExpressionErrorMessage");
214                         Assert.AreEqual ("Password is required.", w.PasswordRequiredErrorMessage, "PasswordRequiredErrorMessage");
215                         Assert.AreEqual ("Security Question:", w.QuestionLabelText, "QuestionLabelText");
216                         Assert.AreEqual ("Security question is required.", w.QuestionRequiredErrorMessage, "QuestionRequiredErrorMessage");
217                         Assert.IsTrue (w.RequireEmail, "RequireEmail");
218                         Assert.AreEqual ("Your account was not created. Please try again.", w.UnknownErrorMessage, "UnknownErrorMessage");
219                         Assert.AreEqual ("User Name:", w.UserNameLabelText, "UserNameLabelText");
220                         Assert.AreEqual ("User Name is required.", w.UserNameRequiredErrorMessage, "UserNameRequiredErrorMessage");
221                         Assert.IsNotNull (w.WizardSteps, "WizardSteps");
222                 }
223
224                 [Test]
225                 public void AssignToDefaultProperties ()
226                 {
227                         TestCreateUserWizard w = new TestCreateUserWizard ();
228                         Assert.AreEqual (0, w.Attributes.Count, "Attributes.Count");
229                         Assert.AreEqual (0, w.StateBag.Count, "ViewState.Count");
230
231                         int count = 0;
232
233                         w.AnswerLabelText = "value";
234                         Assert.AreEqual ("value", w.AnswerLabelText, "CancelButtonImageUrl");
235                         Assert.AreEqual (++count, w.StateBag.Count, "ViewState.Count-1");
236
237                         w.AutoGeneratePassword = true;
238                         Assert.AreEqual (true, w.AutoGeneratePassword, "Assign AutoGeneratePassword");
239                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate AutoGeneratePassword");
240
241                         w.CompleteSuccessText = "text";
242                         Assert.AreEqual ("text", w.CompleteSuccessText, "Assign CompleteSuccessText");
243                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate CompleteSuccessText");
244
245                         w.ConfirmPasswordCompareErrorMessage = "text";
246                         Assert.AreEqual ("text", w.ConfirmPasswordCompareErrorMessage, "Assign ConfirmPasswordCompareErrorMessage,");
247                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ConfirmPasswordCompareErrorMessage,");
248
249                         w.ConfirmPasswordLabelText = "text";
250                         Assert.AreEqual ("text", w.ConfirmPasswordLabelText, "Assign ConfirmPasswordLabelText");
251                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ConfirmPasswordLabelText");
252
253                         w.ConfirmPasswordRequiredErrorMessage = "text";
254                         Assert.AreEqual ("text", w.ConfirmPasswordRequiredErrorMessage, "Assign ConfirmPasswordRequiredErrorMessage");
255                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ConfirmPasswordRequiredErrorMessage");
256
257                         w.ContinueButtonImageUrl = "text";
258                         Assert.AreEqual ("text", w.ContinueButtonImageUrl, "Assign ContinueButtonImageUrl");
259                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ContinueButtonImageUrl");
260
261                         w.ContinueButtonText = "text";
262                         Assert.AreEqual ("text", w.ContinueButtonText, "Assign ContinueButtonText");
263                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ContinueButtonText");
264
265                         //w.ContinueButtonType = ButtonType.Button;
266                         //Assert.AreEqual(ButtonType.Button, w.ContinueButtonType, "Assign ContinueButtonType");
267                         //Assert.AreEqual(count, w.StateBag.Count, "Viewstate ContinueButtonType");
268
269                         w.ContinueDestinationPageUrl = "text";
270                         Assert.AreEqual ("text", w.ContinueDestinationPageUrl, "Assign ContinueDestinationPageUrl");
271                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ContinueDestinationPageUrl");
272
273                         w.CreateUserButtonImageUrl = "text";
274                         Assert.AreEqual ("text", w.CreateUserButtonImageUrl, "Assign CreateUserButtonImageUrl");
275                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate CreateUserButtonImageUrl");
276
277                         w.CreateUserButtonText = "text";
278                         Assert.AreEqual ("text", w.CreateUserButtonText, "Assign CreateUserButtonText");
279                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate CreateUserButtonText");
280
281                         //w.CreateUserButtonType = ButtonType.Button;
282                         //Assert.AreEqual(ButtonType.Button, w.CreateUserButtonType, "Assign CreateUserButtonType");
283                         //Assert.AreEqual(count, w.StateBag.Count, "Viewstate CreateUserButtonType");
284
285                         w.DisableCreatedUser = false;
286                         Assert.AreEqual (false, w.DisableCreatedUser, "Assign DisableCreatedUser");
287                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate DisableCreatedUser");
288
289                         w.DuplicateEmailErrorMessage = "msg";
290                         Assert.AreEqual ("msg", w.DuplicateEmailErrorMessage, "Assign DuplicateEmailErrorMessage");
291                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate DuplicateEmailErrorMessage");
292
293                         w.DuplicateUserNameErrorMessage = "msg";
294                         Assert.AreEqual ("msg", w.DuplicateUserNameErrorMessage, "Assign DuplicateUserNameErrorMessage");
295                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate DuplicateUserNameErrorMessage");
296
297                         w.EditProfileIconUrl = "msg";
298                         Assert.AreEqual ("msg", w.EditProfileIconUrl, "Assign EditProfileIconUrl");
299                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EditProfileIconUrl");
300
301                         w.EditProfileText = "msg";
302                         Assert.AreEqual ("msg", w.EditProfileText, "Assign EditProfileText");
303                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EditProfileText");
304
305                         w.EditProfileUrl = "msg";
306                         Assert.AreEqual ("msg", w.EditProfileUrl, "Assign EditProfileUrl");
307                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EditProfileUrl");
308
309                         w.EmailLabelText = "msg";
310                         Assert.AreEqual ("msg", w.EmailLabelText, "Assign EmailLabelText");
311                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailLabelText");
312
313                         w.EmailRegularExpression = "msg";
314                         Assert.AreEqual ("msg", w.EmailRegularExpression, "Assign EmailRegularExpression");
315                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailRegularExpression");
316
317                         w.EmailRegularExpressionErrorMessage = "msg";
318                         Assert.AreEqual ("msg", w.EmailRegularExpressionErrorMessage, "Assign EmailRegularExpressionErrorMessage");
319                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailRegularExpressionErrorMessage");
320
321                         w.EmailRequiredErrorMessage = "msg";
322                         Assert.AreEqual ("msg", w.EmailRequiredErrorMessage, "Assign EmailRequiredErrorMessage");
323                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailRequiredErrorMessage");
324
325                         w.HelpPageIconUrl = "msg";
326                         Assert.AreEqual ("msg", w.HelpPageIconUrl, "Assign HelpPageIconUrl");
327                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate HelpPageIconUrl");
328
329                         w.HelpPageText = "msg";
330                         Assert.AreEqual ("msg", w.HelpPageText, "Assign HelpPageText");
331                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate HelpPageText");
332
333                         w.HelpPageUrl = "msg";
334                         Assert.AreEqual ("msg", w.HelpPageUrl, "Assign HelpPageUrl");
335                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate HelpPageUrl");
336
337                         w.InstructionText = "msg";
338                         Assert.AreEqual ("msg", w.InstructionText, "Assign InstructionText");
339                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InstructionText");
340
341                         w.InvalidAnswerErrorMessage = "msg";
342                         Assert.AreEqual ("msg", w.InvalidAnswerErrorMessage, "Assign InvalidAnswerErrorMessage");
343                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidAnswerErrorMessage");
344
345                         w.InvalidEmailErrorMessage = "msg";
346                         Assert.AreEqual ("msg", w.InvalidEmailErrorMessage, "Assign InvalidEmailErrorMessage");
347                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidEmailErrorMessage");
348
349                         w.InvalidPasswordErrorMessage = "msg";
350                         Assert.AreEqual ("msg", w.InvalidPasswordErrorMessage, "Assign InvalidPasswordErrorMessage");
351                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidPasswordErrorMessage");
352
353                         w.InvalidQuestionErrorMessage = "msg";
354                         Assert.AreEqual ("msg", w.InvalidQuestionErrorMessage, "Assign InvalidQuestionErrorMessage");
355                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidQuestionErrorMessage");
356
357                         w.LoginCreatedUser = false;
358                         Assert.AreEqual (false, w.LoginCreatedUser, "Assign LoginCreatedUser");
359                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate LoginCreatedUser");
360
361                         w.MembershipProvider = "msg";
362                         Assert.AreEqual ("msg", w.MembershipProvider, "Assign MembershipProvider");
363                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate MembershipProvider");
364
365                         w.PasswordHintText = "msg";
366                         Assert.AreEqual ("msg", w.PasswordHintText, "Assign PasswordHintText");
367                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordHintText");
368
369                         w.PasswordLabelText = "msg";
370                         Assert.AreEqual ("msg", w.PasswordLabelText, "Assign PasswordLabelText");
371                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordLabelText");
372
373                         w.PasswordRegularExpression = "msg";
374                         Assert.AreEqual ("msg", w.PasswordRegularExpression, "Assign PasswordRegularExpression");
375                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordRegularExpression");
376
377                         w.PasswordRegularExpressionErrorMessage = "msg";
378                         Assert.AreEqual ("msg", w.PasswordRegularExpressionErrorMessage, "Assign PasswordRegularExpressionErrorMessage");
379                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordRegularExpressionErrorMessage");
380
381                         w.PasswordRequiredErrorMessage = "msg";
382                         Assert.AreEqual ("msg", w.PasswordRequiredErrorMessage, "Assign PasswordRequiredErrorMessage");
383                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordRequiredErrorMessage");
384
385                         w.QuestionLabelText = "msg";
386                         Assert.AreEqual ("msg", w.QuestionLabelText, "Assign QuestionLabelText");
387                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate QuestionLabelText");
388
389                         w.QuestionRequiredErrorMessage = "msg";
390                         Assert.AreEqual ("msg", w.QuestionRequiredErrorMessage, "Assign QuestionRequiredErrorMessage");
391                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate QuestionRequiredErrorMessage");
392
393                         w.RequireEmail = false;
394                         Assert.AreEqual (false, w.RequireEmail, "Assign RequireEmail");
395                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate RequireEmail");
396
397                         w.UnknownErrorMessage = "msg";
398                         Assert.AreEqual ("msg", w.UnknownErrorMessage, "Assign UnknownErrorMessage");
399                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate UnknownErrorMessage");
400
401                         w.UserNameLabelText = "msg";
402                         Assert.AreEqual ("msg", w.UserNameLabelText, "Assign UserNameLabelText");
403                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate UserNameLabelText");
404
405                         w.UserNameRequiredErrorMessage = "msg";
406                         Assert.AreEqual ("msg", w.UserNameRequiredErrorMessage, "Assign UserNameRequiredErrorMessage");
407                         Assert.AreEqual (++count, w.StateBag.Count, "Viewstate UserNameRequiredErrorMessage");
408
409
410
411                 }
412
413                 public static void BasicRenderTestInit (Page p)
414                 {
415                         CreateTestControl (p);
416                 }
417
418                 public static CreateUserWizard CreateTestControl (Page p)
419                 {
420                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
421                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
422
423                         CreateUserWizard w = new CreateUserWizard ();
424                         w.ID = "CreateUserWizard1";
425
426                         CreateUserWizardStep step1 = new CreateUserWizardStep ();
427                         CompleteWizardStep step2 = new CompleteWizardStep ();
428
429                         w.MembershipProvider = "FakeProvider";
430                         w.WizardSteps.Add (step1);
431                         w.WizardSteps.Add (step2);
432
433                         p.Form.Controls.Add (lcb);
434                         p.Form.Controls.Add (w);
435                         p.Form.Controls.Add (lce);
436
437                         //p.ClientScript.RegisterForEventValidation (w.ID);
438
439                         return w;
440                 }
441
442                 [Test]
443                 [Category ("NunitWeb")]
444                 public void BasicRenderTest ()
445                 {
446                         string html = new WebTest (PageInvoker.CreateOnLoad (
447                                 new PageDelegate (BasicRenderTestInit))).Run ();
448
449                         int st = 0;
450                         Assert.IsTrue ((st = html.IndexOf ("<table", st)) > 0, "base render test 1");
451                         Assert.IsTrue ((st = html.IndexOf ("CreateUserWizard1", st)) > 0, "base render test 2");
452                         Assert.IsTrue ((st = html.IndexOf ("border-collapse:collapse", st)) > 0, "base render test 3");
453                         Assert.IsTrue ((st = html.IndexOf ("<table", st)) > 0, "base render test 4");
454                         Assert.IsTrue ((st = html.IndexOf ("height:100%", st)) > 0, "base render test 5");
455                         Assert.IsTrue ((st = html.IndexOf ("Sign Up for Your New Account", st)) > 0, "base render test 6");
456                         Assert.IsTrue ((st = html.IndexOf ("UserName", st)) > 0, "base render test 7");
457                         Assert.IsTrue ((st = html.IndexOf ("User Name:", st)) > 0, "base render test 8");
458                         Assert.IsTrue ((st = html.IndexOf ("UserName", st)) > 0, "base render test 9");
459                         Assert.IsTrue ((st = html.IndexOf ("Password", st)) > 0, "base render test 10");
460                         Assert.IsTrue ((st = html.IndexOf ("Password:", st)) > 0, "base render test 11");
461                         Assert.IsTrue ((st = html.IndexOf ("Password", st)) > 0, "base render test 12");
462                         Assert.IsTrue ((st = html.IndexOf ("ConfirmPassword", st)) > 0, "base render test 13");
463                         Assert.IsTrue ((st = html.IndexOf ("Confirm Password:", st)) > 0, "base render test 14");
464                         Assert.IsTrue ((st = html.IndexOf ("ConfirmPassword", st)) > 0, "base render test 15");
465                         Assert.IsTrue ((st = html.IndexOf ("Email", st)) > 0, "base render test 16");
466                         Assert.IsTrue ((st = html.IndexOf ("E-mail:", st)) > 0, "base render test 17");
467                         Assert.IsTrue ((st = html.IndexOf ("Email", st)) > 0, "base render test 18");
468                         Assert.IsTrue ((st = html.IndexOf ("Question", st)) > 0, "base render test 19");
469                         Assert.IsTrue ((st = html.IndexOf ("Security Question:", st)) > 0, "base render test 20");
470                         Assert.IsTrue ((st = html.IndexOf ("Question", st)) > 0, "base render test 21");
471                         Assert.IsTrue ((st = html.IndexOf ("Answer", st)) > 0, "base render test 22");
472                         Assert.IsTrue ((st = html.IndexOf ("Security Answer:", st)) > 0, "base render test 23");
473                         Assert.IsTrue ((st = html.IndexOf ("Answer", st)) > 0, "base render test 24");
474                         Assert.IsTrue ((st = html.IndexOf ("<input", st)) > 0, "base render test 25");
475                         Assert.IsTrue ((st = html.IndexOf ("submit", st)) > 0, "base render test 26");
476                         Assert.IsTrue ((st = html.IndexOf ("NextButton", st)) > 0, "base render test 27");
477                 }
478
479                 [Test]
480                 [Category ("NunitWeb")]
481                 public void TitlesRenderTest ()
482                 {
483                         string html = new WebTest (PageInvoker.CreateOnLoad (
484                                 new PageDelegate (TitlesRenderTestInit))).Run ();
485
486                         Assert.IsTrue (html.IndexOf ("userid") > 0, "UserNameLabelText");
487                         Assert.IsTrue (html.IndexOf ("pincode") > 0, "PasswordLabelText");
488                         Assert.IsTrue (html.IndexOf ("cpincode") > 0, "ConfirmPasswordLabelText");
489                         Assert.IsTrue (html.IndexOf ("zzxcmnmncx") > 0, "QuestionLabelText");
490                         Assert.IsTrue (html.IndexOf ("kjkjskjkjskjkj") > 0, "AnswerLabelText");
491                         Assert.IsTrue (html.IndexOf ("emailemail") > 0, "EmailLabelText");
492                 }
493
494                 public static void TitlesRenderTestInit (Page p)
495                 {
496                         CreateUserWizard w = CreateTestControl (p);
497                         w.UserNameLabelText = "userid";
498                         w.PasswordLabelText = "pincode";
499                         w.ConfirmPasswordLabelText = "cpincode";
500                         w.QuestionLabelText = "zzxcmnmncx";
501                         w.AnswerLabelText = "kjkjskjkjskjkj";
502                         w.EmailLabelText = "emailemail";
503                 }
504
505                 [Test]
506                 [Category ("NunitWeb")]
507                 public void ExtraTitlesRenderTest ()
508                 {
509                         string html = new WebTest (PageInvoker.CreateOnLoad (
510                                 new PageDelegate (ExtraTitlesRenderTestInit))).Run ();
511
512                         Assert.IsTrue (html.IndexOf ("PasswordHintText") > 0, "PasswordHintText");
513                         Assert.IsTrue (html.IndexOf ("InstructionText") > 0, "InstructionText");
514                         Assert.IsTrue (html.IndexOf ("http://www.HelpPageUrl.com") > 0, "HelpPageUrl");
515                         Assert.IsTrue (html.IndexOf ("HelpPageText") > 0, "HelpPageText");
516                         Assert.IsTrue (html.IndexOf ("http://www.HelpPageIconUrl.com") > 0, "HelpPageIconUrl");
517                         Assert.IsTrue (html.IndexOf ("CreateUserButtonText") > 0, "CreateUserButtonText");
518                         Assert.IsTrue (html.IndexOf ("CreateUserStep.Title") > 0, "CreateUserStep.Title");
519                 }
520
521                 public static void ExtraTitlesRenderTestInit (Page p)
522                 {
523                         CreateUserWizard w = CreateTestControl (p);
524                         w.PasswordHintText = "PasswordHintText";
525                         w.InstructionText = "InstructionText";
526                         w.HelpPageUrl = "http://www.HelpPageUrl.com";
527                         w.HelpPageText = "HelpPageText";
528                         w.HelpPageIconUrl = "http://www.HelpPageIconUrl.com";
529                         w.CreateUserStep.Title = "CreateUserStep.Title";
530                         w.CreateUserButtonText = "CreateUserButtonText";
531                 }
532
533                 [Test]
534                 [Category ("NunitWeb")]
535                 public void StylesRenderTest ()
536                 {
537                         string html = new WebTest (PageInvoker.CreateOnLoad (
538                                 new PageDelegate (StylesRenderTestInit))).Run ();
539
540                         Assert.IsTrue (html.IndexOf ("LightGoldenrodYellow;") > 0, "TextBoxStyle");
541                         Assert.IsTrue (html.LastIndexOf ("LightGoldenrodYellow;") > html.IndexOf ("LightGoldenrodYellow;"), "TextBoxStyle2");
542                         Assert.IsTrue (html.IndexOf ("732px") > 0, "TitleTextStyle");
543                         Assert.IsTrue (html.IndexOf ("LightSkyBlue;") > 0, "HyperLinkStyle");
544                         Assert.IsTrue (html.IndexOf ("MediumSeaGreen;") > 0, "InstructionTextStyle");
545                         Assert.IsTrue (html.IndexOf ("MediumSpringGreen;") > 0, "LabelStyle");
546                         Assert.IsTrue (html.IndexOf ("MintCream;") > 0, "PasswordHintStyle");
547                         Assert.IsTrue (html.IndexOf ("PeachPuff;") > 0, "CreateUserButtonStyle");
548
549                 }
550
551                 private string GetDecoratedId (string html, string id)
552                 {
553                         Regex reg = new Regex ("name=\".*[\\$\\:]" + id + "\"");
554                         Match match = reg.Match (html);
555
556                         string fixedId = match.Value;
557                         if (fixedId.Length > 0)
558                                 fixedId = fixedId.Substring (fixedId.IndexOf ("\""), fixedId.Length - fixedId.IndexOf ("\"")).Trim ('\"');
559
560                         return fixedId;
561                 }
562
563                 private static string GetEventTarget (string html, string id)
564                 {
565                         Regex reg = new Regex ("__doPostBack.*\\(.*'.*" + id + "'");
566                         Match match = reg.Match (html);
567
568                         string fixedId = match.Value;
569                         if (fixedId.Length > 0)
570                                 fixedId = fixedId.Substring (fixedId.IndexOf ("'"), fixedId.Length - fixedId.IndexOf ("'")).Trim ('\'');
571
572                         return fixedId;
573                 }
574
575                 [Test]
576                 [Category ("NunitWeb")]
577                 public void BasicPostbackTest ()
578                 {
579                         PageInvoker pi = PageInvoker.CreateOnLoad (new PageDelegate (StylesRenderTestInit));
580                         WebTest test = new WebTest (pi);
581
582                         string html = test.Run ();
583                         test.Invoker = pi;
584
585                         FormRequest fr = new FormRequest (test.Response, "form1");
586
587                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "username"));
588                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "password"));
589                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "password"));
590                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "email"));
591                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "question"));
592                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "answer"));
593
594                         PageDelegates pd = new PageDelegates ();
595                         pd.PreRender = new PageDelegate (BasicPostTestPreRender);
596                         pd.Load = new PageDelegate (StylesRenderTestInit);
597                         pi.Delegates = pd;
598
599                         test.Request = fr;
600                         html = test.Run ();
601
602                         Assert.IsTrue (html.IndexOf ("username") > 0, "rendered user name");
603                         Assert.IsTrue (html.IndexOf ("password") > 0, "rendered user password");
604                         Assert.IsTrue (html.IndexOf ("password") > 0, "rendered user confirm password");
605                         Assert.IsTrue (html.IndexOf ("email") > 0, "rendered user email");
606                         Assert.IsTrue (html.IndexOf ("question") > 0, "rendered user question");
607                         Assert.IsTrue (html.IndexOf ("answer") > 0, "rendered user answer");
608
609                         Assert.IsTrue (html.IndexOf ("LightGoldenrodYellow;") > 0, "TextBoxStyle");
610                         Assert.IsTrue (html.LastIndexOf ("LightGoldenrodYellow;") > html.IndexOf ("LightGoldenrodYellow;"), "TextBoxStyle2");
611                         Assert.IsTrue (html.IndexOf ("732px") > 0, "TitleTextStyle");
612                         Assert.IsTrue (html.IndexOf ("LightSkyBlue;") > 0, "HyperLinkStyle");
613                         Assert.IsTrue (html.IndexOf ("MediumSeaGreen;") > 0, "InstructionTextStyle");
614                         Assert.IsTrue (html.IndexOf ("MediumSpringGreen;") > 0, "LabelStyle");
615                         Assert.IsTrue (html.IndexOf ("MintCream;") > 0, "PasswordHintStyle");
616                         Assert.IsTrue (html.IndexOf ("PeachPuff;") > 0, "CreateUserButtonStyle");
617                 }
618
619                 public static void BasicPostTestPreRender (Page p)
620                 {
621                         CreateUserWizard w = (CreateUserWizard) p.FindControl ("CreateUserWizard1");
622                         if (w == null)
623                                 Assert.Fail ("postback1");
624
625                         Assert.AreEqual ("username", w.UserName, "posted user name");
626                         Assert.AreEqual ("password", w.Password, "posted user password");
627                         Assert.AreEqual ("password", w.ConfirmPassword, "posted user confirm password");
628                         Assert.AreEqual ("email", w.Email, "posted user email");
629                         Assert.AreEqual ("question", w.Question, "posted user question");
630                         Assert.AreEqual ("answer", w.Answer, "posted user answer");
631
632                 }
633
634                 public static void StylesRenderTestInit (Page p)
635                 {
636                         CreateUserWizard w = CreateTestControl (p);
637
638                         if (!p.IsPostBack) {
639                                 w.TextBoxStyle.BackColor = Color.LightGoldenrodYellow;
640                                 w.TitleTextStyle.Height = Unit.Pixel (732);
641                                 w.LabelStyle.BackColor = Color.MediumSpringGreen;
642
643                                 w.HelpPageUrl = "http://www.HelpPageUrl.com";
644                                 w.HelpPageText = "hhh";
645                                 w.HyperLinkStyle.BackColor = Color.LightSkyBlue;
646
647                                 w.InstructionText = "text";
648                                 w.InstructionTextStyle.BackColor = Color.MediumSeaGreen;
649
650                                 w.PasswordHintText = "pwdhint";
651                                 w.PasswordHintStyle.BackColor = Color.MintCream;
652
653                                 w.CreateUserButtonStyle.BackColor = Color.PeachPuff;
654
655                                 w.ContinueButtonType = ButtonType.Image;
656                                 w.ContinueButtonStyle.Width = Unit.Pixel (321);
657                                 w.ContinueButtonImageUrl = "http://localhost/abc.gif";
658
659                                 w.CompleteSuccessTextStyle.BackColor = Color.Violet;
660                                 w.CompleteSuccessText = "user created";
661                         }
662                 }
663
664                 // TODO:
665                 // ValidatorTextStyle
666                 // ErrorMessageStyle
667                 [Test]
668                 [Category ("NunitWeb")]
669                 public void CreateUserTest ()
670                 {
671                         PageInvoker pi = PageInvoker.CreateOnLoad (new PageDelegate (StylesRenderTestInit));
672                         WebTest test = new WebTest (pi);
673
674                         string html = test.Run ();
675                         test.Invoker = pi;
676
677                         FormRequest fr = new FormRequest (test.Response, "form1");
678
679                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "username"));
680                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "password"));
681                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "password"));
682                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "email"));
683                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "question"));
684                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "answer"));
685                         string button = GetDecoratedId (html, "StepNextButtonButton");
686                         if (button.Length > 0)
687                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
688                         else
689                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
690                                 //fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
691
692                         test.Request = fr;
693                         html = test.Run ();
694
695                         Assert.IsTrue (html.IndexOf ("Complete") > 0, "Create User");
696                         Assert.IsTrue (html.IndexOf ("type=\"image\"") > 0, "ContinueButtonType");
697                         Assert.IsTrue (html.IndexOf ("321px") > 0, "ContinueButtonStyle");
698                         Assert.IsTrue (html.IndexOf ("http://localhost/abc.gif") > 0, "ContinueButtonImageUrl");
699                         Assert.IsTrue (html.IndexOf ("Violet") > 0, "CompleteSuccessTextStyle");
700                         Assert.IsTrue (html.IndexOf ("user created") > 0, "CompleteSuccessText");
701                 }
702
703
704                 [Test]
705                 [Category ("NunitWeb")]
706                 public void ButtonsRenderTest ()
707                 {
708                         string html = new WebTest (PageInvoker.CreateOnLoad (
709                                 new PageDelegate (ButtonsRenderTestInit))).Run ();
710
711                         Assert.IsTrue (html.IndexOf ("Pink;") > 0, "CreateUserButtonStyle");
712                         Assert.IsTrue (html.IndexOf ("14px") > 0, "CreateUserButtonStyle");
713                         Assert.IsTrue (html.IndexOf ("CreateUserButtonText") > 0, "CreateUserButtonText");
714                 }
715
716                 public static void ButtonsRenderTestInit (Page p)
717                 {
718                         CreateUserWizard w = CreateTestControl (p);
719                         w.CreateUserButtonStyle.BorderColor = Color.Pink;
720                         w.CreateUserButtonStyle.BorderWidth = Unit.Pixel (14);
721                         w.CreateUserButtonType = ButtonType.Link;
722                         w.CreateUserButtonText = "CreateUserButtonText";
723                 }
724
725                 [Test]
726                 [Category ("NunitWeb")]
727                 public void ErrorMsgTest ()
728                 {
729                         PageInvoker pi = PageInvoker.CreateOnLoad (new PageDelegate (ErrorMsgTestInit));
730                         WebTest test = new WebTest (pi);
731
732                         string html = test.Run ();
733                         test.Invoker = pi;
734
735                         FormRequest fr = new FormRequest (test.Response, "form1");
736                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "duplicate"));
737                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "123"));
738                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "123"));
739                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "123"));
740                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "123"));
741                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
742                         string button = GetDecoratedId (html, "StepNextButtonButton");
743                         if (button.Length > 0)
744                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
745                         else
746                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
747
748                         test.Request = fr;
749                         html = test.Run ();
750
751                         Assert.IsTrue (html.IndexOf ("duplicateuser") > 0, "duplicateuser");
752
753                         test.Invoker = pi;
754                         fr = new FormRequest (test.Response, "form1");
755                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "incorrect"));
756                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "123"));
757                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "123"));
758                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "123"));
759                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "123"));
760                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
761                         button = GetDecoratedId (html, "StepNextButtonButton");
762                         if (button.Length > 0)
763                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
764                         else
765                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
766
767                         test.Request = fr;
768                         html = test.Run ();
769
770                         Assert.IsTrue (html.IndexOf ("unknown") > 0, "unknown");
771
772                         test.Invoker = pi;
773                         fr = new FormRequest (test.Response, "form1");
774                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "123"));
775                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "incorrect"));
776                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "incorrect"));
777                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "123"));
778                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "123"));
779                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
780                         button = GetDecoratedId (html, "StepNextButtonButton");
781                         if (button.Length > 0)
782                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
783                         else
784                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
785
786                         test.Request = fr;
787                         html = test.Run ();
788
789                         Assert.IsTrue (html.IndexOf ("invpwd") > 0, "invpwd");
790
791                         test.Invoker = pi;
792                         fr = new FormRequest (test.Response, "form1");
793                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "123"));
794                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "123"));
795                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "123"));
796                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "incorrect"));
797                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "123"));
798                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
799                         button = GetDecoratedId (html, "StepNextButtonButton");
800                         if (button.Length > 0)
801                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
802                         else
803                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
804
805                         test.Request = fr;
806                         html = test.Run ();
807
808                         Assert.IsTrue (html.IndexOf ("invemail") > 0, "invemail");
809
810                         test.Invoker = pi;
811                         fr = new FormRequest (test.Response, "form1");
812                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "123"));
813                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "123"));
814                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "123"));
815                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "duplicate"));
816                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "123"));
817                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
818                         button = GetDecoratedId (html, "StepNextButtonButton");
819                         if (button.Length > 0)
820                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
821                         else
822                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
823
824                         test.Request = fr;
825                         html = test.Run ();
826
827                         Assert.IsTrue (html.IndexOf ("duplicateemail") > 0, "duplicateemail");
828
829                         test.Invoker = pi;
830                         fr = new FormRequest (test.Response, "form1");
831                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "123"));
832                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "123"));
833                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "123"));
834                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "123"));
835                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "incorrect"));
836                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
837                         button = GetDecoratedId (html, "StepNextButtonButton");
838                         if (button.Length > 0)
839                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
840                         else
841                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
842
843                         test.Request = fr;
844                         html = test.Run ();
845
846                         Assert.IsTrue (html.IndexOf ("invquestion") > 0, "invquestion");
847
848                         test.Invoker = pi;
849                         fr = new FormRequest (test.Response, "form1");
850                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "UserName"), "123"));
851                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Password"), "123"));
852                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "ConfirmPassword"), "123"));
853                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Email"), "123"));
854                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Question"), "123"));
855                         fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "incorrect"));
856                         button = GetDecoratedId (html, "StepNextButtonButton");
857                         if (button.Length > 0)
858                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
859                         else
860                                 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
861
862                         test.Request = fr;
863                         html = test.Run ();
864
865                         Assert.IsTrue (html.IndexOf ("invanswer") > 0, "invanswer");
866                 }
867
868                 public static void ErrorMsgTestInit (Page p)
869                 {
870                         CreateUserWizard w = CreateTestControl (p);
871
872                         if (!p.IsPostBack) {
873                                 w.AnswerRequiredErrorMessage = "answerreq";
874                                 w.ConfirmPasswordCompareErrorMessage = "passwordconfirm";
875                                 w.ConfirmPasswordRequiredErrorMessage = "passwordconfreq";
876                                 w.DuplicateEmailErrorMessage = "duplicateemail";
877                                 w.DuplicateUserNameErrorMessage = "duplicateuser";
878                                 w.EmailRequiredErrorMessage = "emailreq";
879                                 w.InvalidAnswerErrorMessage = "invanswer";
880                                 w.InvalidEmailErrorMessage = "invemail";
881                                 w.InvalidPasswordErrorMessage = "invpwd";
882                                 w.InvalidQuestionErrorMessage = "invquestion";
883                                 w.PasswordRequiredErrorMessage = "pwdreq";
884                                 w.QuestionRequiredErrorMessage = "questreq";
885                                 w.UserNameRequiredErrorMessage = "userreq";
886                                 w.UnknownErrorMessage = "unknown";
887                         }
888                 }
889
890                 [Test]
891                 public void BibbleEvent_ContinueButtonCommand ()
892                 {
893                         TestCreateUserWizard w = new TestCreateUserWizard ();
894                         w.ContinueButtonClick += new EventHandler (w_ContinueButtonClick);
895                         w.FinishButtonClick += new WizardNavigationEventHandler (w_FinishButtonClick);
896                         _ContinueButtonClickFlag = false;
897                         _FinishButtonClickFlag = false;
898
899                         CommandEventArgs continueCommandArg = new CommandEventArgs (CreateUserWizard.ContinueButtonCommandName, null);
900                         Assert.AreEqual (true, w.DoOnBubbleEvent (continueCommandArg), "Bubble Event#1");
901                         Assert.AreEqual (true, _ContinueButtonClickFlag, "Bubble Event#2");
902                         Assert.AreEqual (false, _FinishButtonClickFlag, "Bubble Event#3");
903                 }
904
905                 bool _ContinueButtonClickFlag;
906                 bool _FinishButtonClickFlag;
907
908                 void w_ContinueButtonClick (object sender, EventArgs e)
909                 {
910                         _ContinueButtonClickFlag = true;
911                 }
912
913                 void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)
914                 {
915                         _FinishButtonClickFlag = true;
916                 }
917         }
918 }
919
920 #endif