2 // WizardTest.cs - Unit tests for System.Web.UI.WebControls.Wizard
5 // Vladimir Krasnov <vladimirk@mainsoft.com>
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
33 using System.Threading;
34 using System.Collections;
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;
44 using NUnit.Framework;
46 namespace MonoTests.System.Web.UI.WebControls
49 public class TestCreateUserWizard : CreateUserWizard
54 get { return base.TagName; }
57 public StateBag StateBag
59 get { return base.ViewState; }
62 public string Render ()
64 StringWriter sw = new StringWriter ();
66 HtmlTextWriter writer = new HtmlTextWriter (sw);
68 return writer.InnerWriter.ToString ();
71 public Style GetStyle ()
73 return base.CreateControlStyle ();
76 public void TrackState ()
81 public void LoadState (object state)
83 LoadViewState (state);
86 public object SaveState ()
88 return SaveViewState ();
91 public void SetDesignMode (IDictionary dic)
93 base.SetDesignModeState (dic);
96 private bool onBubble;
98 public bool OnBubbleEventCalled
100 get { return onBubble; }
101 set { onBubble = value; }
104 protected override bool OnBubbleEvent (object source, EventArgs e)
107 return base.OnBubbleEvent (source, e);
110 public bool DoBubbleEvent (object source, EventArgs e)
112 return base.OnBubbleEvent (source, e);
115 public void DoEnsureChildControls ()
117 base.EnsureChildControls ();
120 public bool DoOnBubbleEvent (EventArgs e)
122 return base.OnBubbleEvent (this, e);
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;
130 ActiveStepIndex_After_Init = ActiveStepIndex;
136 public class CreateUserWizardTest
139 [TestFixtureTearDown]
140 public void Unload ()
146 [Category ("NunitWeb")]
148 [Ignore ("TD #7024")]
150 public void ActiveStepIndex () {
151 new WebTest (PageInvoker.CreateOnLoad (ActiveStepIndex_Load)).Run ();
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);
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);
170 public void DefaultProperties ()
172 TestCreateUserWizard w = new TestCreateUserWizard ();
173 Assert.AreEqual (0, w.Attributes.Count, "Attributes.Count");
174 Assert.AreEqual (0, w.StateBag.Count, "ViewState.Count");
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");
225 public void AssignToDefaultProperties ()
227 TestCreateUserWizard w = new TestCreateUserWizard ();
228 Assert.AreEqual (0, w.Attributes.Count, "Attributes.Count");
229 Assert.AreEqual (0, w.StateBag.Count, "ViewState.Count");
233 w.AnswerLabelText = "value";
234 Assert.AreEqual ("value", w.AnswerLabelText, "CancelButtonImageUrl");
235 Assert.AreEqual (++count, w.StateBag.Count, "ViewState.Count-1");
237 w.AutoGeneratePassword = true;
238 Assert.AreEqual (true, w.AutoGeneratePassword, "Assign AutoGeneratePassword");
239 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate AutoGeneratePassword");
241 w.CompleteSuccessText = "text";
242 Assert.AreEqual ("text", w.CompleteSuccessText, "Assign CompleteSuccessText");
243 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate CompleteSuccessText");
245 w.ConfirmPasswordCompareErrorMessage = "text";
246 Assert.AreEqual ("text", w.ConfirmPasswordCompareErrorMessage, "Assign ConfirmPasswordCompareErrorMessage,");
247 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ConfirmPasswordCompareErrorMessage,");
249 w.ConfirmPasswordLabelText = "text";
250 Assert.AreEqual ("text", w.ConfirmPasswordLabelText, "Assign ConfirmPasswordLabelText");
251 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ConfirmPasswordLabelText");
253 w.ConfirmPasswordRequiredErrorMessage = "text";
254 Assert.AreEqual ("text", w.ConfirmPasswordRequiredErrorMessage, "Assign ConfirmPasswordRequiredErrorMessage");
255 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ConfirmPasswordRequiredErrorMessage");
257 w.ContinueButtonImageUrl = "text";
258 Assert.AreEqual ("text", w.ContinueButtonImageUrl, "Assign ContinueButtonImageUrl");
259 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ContinueButtonImageUrl");
261 w.ContinueButtonText = "text";
262 Assert.AreEqual ("text", w.ContinueButtonText, "Assign ContinueButtonText");
263 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ContinueButtonText");
265 //w.ContinueButtonType = ButtonType.Button;
266 //Assert.AreEqual(ButtonType.Button, w.ContinueButtonType, "Assign ContinueButtonType");
267 //Assert.AreEqual(count, w.StateBag.Count, "Viewstate ContinueButtonType");
269 w.ContinueDestinationPageUrl = "text";
270 Assert.AreEqual ("text", w.ContinueDestinationPageUrl, "Assign ContinueDestinationPageUrl");
271 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate ContinueDestinationPageUrl");
273 w.CreateUserButtonImageUrl = "text";
274 Assert.AreEqual ("text", w.CreateUserButtonImageUrl, "Assign CreateUserButtonImageUrl");
275 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate CreateUserButtonImageUrl");
277 w.CreateUserButtonText = "text";
278 Assert.AreEqual ("text", w.CreateUserButtonText, "Assign CreateUserButtonText");
279 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate CreateUserButtonText");
281 //w.CreateUserButtonType = ButtonType.Button;
282 //Assert.AreEqual(ButtonType.Button, w.CreateUserButtonType, "Assign CreateUserButtonType");
283 //Assert.AreEqual(count, w.StateBag.Count, "Viewstate CreateUserButtonType");
285 w.DisableCreatedUser = false;
286 Assert.AreEqual (false, w.DisableCreatedUser, "Assign DisableCreatedUser");
287 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate DisableCreatedUser");
289 w.DuplicateEmailErrorMessage = "msg";
290 Assert.AreEqual ("msg", w.DuplicateEmailErrorMessage, "Assign DuplicateEmailErrorMessage");
291 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate DuplicateEmailErrorMessage");
293 w.DuplicateUserNameErrorMessage = "msg";
294 Assert.AreEqual ("msg", w.DuplicateUserNameErrorMessage, "Assign DuplicateUserNameErrorMessage");
295 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate DuplicateUserNameErrorMessage");
297 w.EditProfileIconUrl = "msg";
298 Assert.AreEqual ("msg", w.EditProfileIconUrl, "Assign EditProfileIconUrl");
299 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EditProfileIconUrl");
301 w.EditProfileText = "msg";
302 Assert.AreEqual ("msg", w.EditProfileText, "Assign EditProfileText");
303 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EditProfileText");
305 w.EditProfileUrl = "msg";
306 Assert.AreEqual ("msg", w.EditProfileUrl, "Assign EditProfileUrl");
307 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EditProfileUrl");
309 w.EmailLabelText = "msg";
310 Assert.AreEqual ("msg", w.EmailLabelText, "Assign EmailLabelText");
311 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailLabelText");
313 w.EmailRegularExpression = "msg";
314 Assert.AreEqual ("msg", w.EmailRegularExpression, "Assign EmailRegularExpression");
315 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailRegularExpression");
317 w.EmailRegularExpressionErrorMessage = "msg";
318 Assert.AreEqual ("msg", w.EmailRegularExpressionErrorMessage, "Assign EmailRegularExpressionErrorMessage");
319 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailRegularExpressionErrorMessage");
321 w.EmailRequiredErrorMessage = "msg";
322 Assert.AreEqual ("msg", w.EmailRequiredErrorMessage, "Assign EmailRequiredErrorMessage");
323 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate EmailRequiredErrorMessage");
325 w.HelpPageIconUrl = "msg";
326 Assert.AreEqual ("msg", w.HelpPageIconUrl, "Assign HelpPageIconUrl");
327 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate HelpPageIconUrl");
329 w.HelpPageText = "msg";
330 Assert.AreEqual ("msg", w.HelpPageText, "Assign HelpPageText");
331 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate HelpPageText");
333 w.HelpPageUrl = "msg";
334 Assert.AreEqual ("msg", w.HelpPageUrl, "Assign HelpPageUrl");
335 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate HelpPageUrl");
337 w.InstructionText = "msg";
338 Assert.AreEqual ("msg", w.InstructionText, "Assign InstructionText");
339 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InstructionText");
341 w.InvalidAnswerErrorMessage = "msg";
342 Assert.AreEqual ("msg", w.InvalidAnswerErrorMessage, "Assign InvalidAnswerErrorMessage");
343 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidAnswerErrorMessage");
345 w.InvalidEmailErrorMessage = "msg";
346 Assert.AreEqual ("msg", w.InvalidEmailErrorMessage, "Assign InvalidEmailErrorMessage");
347 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidEmailErrorMessage");
349 w.InvalidPasswordErrorMessage = "msg";
350 Assert.AreEqual ("msg", w.InvalidPasswordErrorMessage, "Assign InvalidPasswordErrorMessage");
351 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidPasswordErrorMessage");
353 w.InvalidQuestionErrorMessage = "msg";
354 Assert.AreEqual ("msg", w.InvalidQuestionErrorMessage, "Assign InvalidQuestionErrorMessage");
355 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate InvalidQuestionErrorMessage");
357 w.LoginCreatedUser = false;
358 Assert.AreEqual (false, w.LoginCreatedUser, "Assign LoginCreatedUser");
359 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate LoginCreatedUser");
361 w.MembershipProvider = "msg";
362 Assert.AreEqual ("msg", w.MembershipProvider, "Assign MembershipProvider");
363 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate MembershipProvider");
365 w.PasswordHintText = "msg";
366 Assert.AreEqual ("msg", w.PasswordHintText, "Assign PasswordHintText");
367 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordHintText");
369 w.PasswordLabelText = "msg";
370 Assert.AreEqual ("msg", w.PasswordLabelText, "Assign PasswordLabelText");
371 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordLabelText");
373 w.PasswordRegularExpression = "msg";
374 Assert.AreEqual ("msg", w.PasswordRegularExpression, "Assign PasswordRegularExpression");
375 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordRegularExpression");
377 w.PasswordRegularExpressionErrorMessage = "msg";
378 Assert.AreEqual ("msg", w.PasswordRegularExpressionErrorMessage, "Assign PasswordRegularExpressionErrorMessage");
379 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordRegularExpressionErrorMessage");
381 w.PasswordRequiredErrorMessage = "msg";
382 Assert.AreEqual ("msg", w.PasswordRequiredErrorMessage, "Assign PasswordRequiredErrorMessage");
383 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate PasswordRequiredErrorMessage");
385 w.QuestionLabelText = "msg";
386 Assert.AreEqual ("msg", w.QuestionLabelText, "Assign QuestionLabelText");
387 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate QuestionLabelText");
389 w.QuestionRequiredErrorMessage = "msg";
390 Assert.AreEqual ("msg", w.QuestionRequiredErrorMessage, "Assign QuestionRequiredErrorMessage");
391 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate QuestionRequiredErrorMessage");
393 w.RequireEmail = false;
394 Assert.AreEqual (false, w.RequireEmail, "Assign RequireEmail");
395 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate RequireEmail");
397 w.UnknownErrorMessage = "msg";
398 Assert.AreEqual ("msg", w.UnknownErrorMessage, "Assign UnknownErrorMessage");
399 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate UnknownErrorMessage");
401 w.UserNameLabelText = "msg";
402 Assert.AreEqual ("msg", w.UserNameLabelText, "Assign UserNameLabelText");
403 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate UserNameLabelText");
405 w.UserNameRequiredErrorMessage = "msg";
406 Assert.AreEqual ("msg", w.UserNameRequiredErrorMessage, "Assign UserNameRequiredErrorMessage");
407 Assert.AreEqual (++count, w.StateBag.Count, "Viewstate UserNameRequiredErrorMessage");
413 public static void BasicRenderTestInit (Page p)
415 CreateTestControl (p);
418 public static CreateUserWizard CreateTestControl (Page p)
420 LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
421 LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
423 CreateUserWizard w = new CreateUserWizard ();
424 w.ID = "CreateUserWizard1";
426 CreateUserWizardStep step1 = new CreateUserWizardStep ();
427 CompleteWizardStep step2 = new CompleteWizardStep ();
429 w.MembershipProvider = "FakeProvider";
430 w.WizardSteps.Add (step1);
431 w.WizardSteps.Add (step2);
433 p.Form.Controls.Add (lcb);
434 p.Form.Controls.Add (w);
435 p.Form.Controls.Add (lce);
437 //p.ClientScript.RegisterForEventValidation (w.ID);
443 [Category ("NunitWeb")]
444 public void BasicRenderTest ()
446 string html = new WebTest (PageInvoker.CreateOnLoad (
447 new PageDelegate (BasicRenderTestInit))).Run ();
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");
480 [Category ("NunitWeb")]
481 public void TitlesRenderTest ()
483 string html = new WebTest (PageInvoker.CreateOnLoad (
484 new PageDelegate (TitlesRenderTestInit))).Run ();
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");
494 public static void TitlesRenderTestInit (Page p)
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";
506 [Category ("NunitWeb")]
507 public void ExtraTitlesRenderTest ()
509 string html = new WebTest (PageInvoker.CreateOnLoad (
510 new PageDelegate (ExtraTitlesRenderTestInit))).Run ();
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");
521 public static void ExtraTitlesRenderTestInit (Page p)
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";
534 [Category ("NunitWeb")]
535 public void StylesRenderTest ()
537 string html = new WebTest (PageInvoker.CreateOnLoad (
538 new PageDelegate (StylesRenderTestInit))).Run ();
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");
551 private string GetDecoratedId (string html, string id)
553 Regex reg = new Regex ("name=\".*[\\$\\:]" + id + "\"");
554 Match match = reg.Match (html);
556 string fixedId = match.Value;
557 if (fixedId.Length > 0)
558 fixedId = fixedId.Substring (fixedId.IndexOf ("\""), fixedId.Length - fixedId.IndexOf ("\"")).Trim ('\"');
563 private static string GetEventTarget (string html, string id)
565 Regex reg = new Regex ("__doPostBack.*\\(.*'.*" + id + "'");
566 Match match = reg.Match (html);
568 string fixedId = match.Value;
569 if (fixedId.Length > 0)
570 fixedId = fixedId.Substring (fixedId.IndexOf ("'"), fixedId.Length - fixedId.IndexOf ("'")).Trim ('\'');
576 [Category ("NunitWeb")]
577 public void BasicPostbackTest ()
579 PageInvoker pi = PageInvoker.CreateOnLoad (new PageDelegate (StylesRenderTestInit));
580 WebTest test = new WebTest (pi);
582 string html = test.Run ();
585 FormRequest fr = new FormRequest (test.Response, "form1");
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"));
594 PageDelegates pd = new PageDelegates ();
595 pd.PreRender = new PageDelegate (BasicPostTestPreRender);
596 pd.Load = new PageDelegate (StylesRenderTestInit);
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");
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");
619 public static void BasicPostTestPreRender (Page p)
621 CreateUserWizard w = (CreateUserWizard) p.FindControl ("CreateUserWizard1");
623 Assert.Fail ("postback1");
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");
634 public static void StylesRenderTestInit (Page p)
636 CreateUserWizard w = CreateTestControl (p);
639 w.TextBoxStyle.BackColor = Color.LightGoldenrodYellow;
640 w.TitleTextStyle.Height = Unit.Pixel (732);
641 w.LabelStyle.BackColor = Color.MediumSpringGreen;
643 w.HelpPageUrl = "http://www.HelpPageUrl.com";
644 w.HelpPageText = "hhh";
645 w.HyperLinkStyle.BackColor = Color.LightSkyBlue;
647 w.InstructionText = "text";
648 w.InstructionTextStyle.BackColor = Color.MediumSeaGreen;
650 w.PasswordHintText = "pwdhint";
651 w.PasswordHintStyle.BackColor = Color.MintCream;
653 w.CreateUserButtonStyle.BackColor = Color.PeachPuff;
655 w.ContinueButtonType = ButtonType.Image;
656 w.ContinueButtonStyle.Width = Unit.Pixel (321);
657 w.ContinueButtonImageUrl = "http://localhost/abc.gif";
659 w.CompleteSuccessTextStyle.BackColor = Color.Violet;
660 w.CompleteSuccessText = "user created";
665 // ValidatorTextStyle
668 [Category ("NunitWeb")]
669 public void CreateUserTest ()
671 PageInvoker pi = PageInvoker.CreateOnLoad (new PageDelegate (StylesRenderTestInit));
672 WebTest test = new WebTest (pi);
674 string html = test.Run ();
677 FormRequest fr = new FormRequest (test.Response, "form1");
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"));
689 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
690 //fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
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");
705 [Category ("NunitWeb")]
706 public void ButtonsRenderTest ()
708 string html = new WebTest (PageInvoker.CreateOnLoad (
709 new PageDelegate (ButtonsRenderTestInit))).Run ();
711 Assert.IsTrue (html.IndexOf ("Pink;") > 0, "CreateUserButtonStyle");
712 Assert.IsTrue (html.IndexOf ("14px") > 0, "CreateUserButtonStyle");
713 Assert.IsTrue (html.IndexOf ("CreateUserButtonText") > 0, "CreateUserButtonText");
716 public static void ButtonsRenderTestInit (Page p)
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";
726 [Category ("NunitWeb")]
727 public void ErrorMsgTest ()
729 PageInvoker pi = PageInvoker.CreateOnLoad (new PageDelegate (ErrorMsgTestInit));
730 WebTest test = new WebTest (pi);
732 string html = test.Run ();
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"));
746 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
751 Assert.IsTrue (html.IndexOf ("duplicateuser") > 0, "duplicateuser");
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"));
765 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
770 Assert.IsTrue (html.IndexOf ("unknown") > 0, "unknown");
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"));
784 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
789 Assert.IsTrue (html.IndexOf ("invpwd") > 0, "invpwd");
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"));
803 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
808 Assert.IsTrue (html.IndexOf ("invemail") > 0, "invemail");
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"));
822 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
827 Assert.IsTrue (html.IndexOf ("duplicateemail") > 0, "duplicateemail");
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"));
841 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
846 Assert.IsTrue (html.IndexOf ("invquestion") > 0, "invquestion");
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"));
860 fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
865 Assert.IsTrue (html.IndexOf ("invanswer") > 0, "invanswer");
868 public static void ErrorMsgTestInit (Page p)
870 CreateUserWizard w = CreateTestControl (p);
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";
891 public void BibbleEvent_ContinueButtonCommand ()
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;
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");
905 bool _ContinueButtonClickFlag;
906 bool _FinishButtonClickFlag;
908 void w_ContinueButtonClick (object sender, EventArgs e)
910 _ContinueButtonClickFlag = true;
913 void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)
915 _FinishButtonClickFlag = true;