CreateUserWizardTest.cs 39 KB

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