PageRenderTime 60ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Orchard.Test/Orchard.Test/Modules/Users/Auto/RequestLostPasswordWithInvaildUserInfo.cs

http://orchardqa.codeplex.com
C# | 89 lines | 55 code | 5 blank | 29 comment | 1 complexity | fbaf79b67db36a8c6ae0c8eab77cc19e MD5 | raw file
  1. /*
  2. Copyright (c) 2010, hiSoft
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the hiSoft nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE HISOFT AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL HISOFT BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. using System;
  26. using Microsoft.VisualStudio.TestTools.UnitTesting;
  27. using Orchard.Test.Library;
  28. using Selenium;
  29. namespace Orchard.Test.Modules.Users.Auto
  30. {
  31. [TestClass]
  32. public class RequestLostPasswordWithInvaildUserInfo
  33. {
  34. private TestLibrary TestLibrary;
  35. private ISelenium selenium;
  36. [TestInitialize]
  37. public void SetupTest()
  38. {
  39. TestLibrary = TestLibrary.SetupTest(this.ToString());
  40. selenium = TestLibrary.Selenium;
  41. }
  42. [TestCleanup]
  43. public void TeardownTest()
  44. {
  45. TestLibrary.ShutDown();
  46. }
  47. [TestMethod]
  48. public void User_RequestLostPasswordWithInvaildUserInfo()
  49. {
  50. TestLibrary.UserHelper.LogOnAsAdmin();
  51. TestLibrary.ModuleHelper.EnableEmail();
  52. //TestLibrary.SettingHelper.ConfigureSmtpSettings("RecoverPassword@microsoft.com", "smtp.microsoft.com", "25", false, false, null, null);
  53. TestLibrary.SettingHelper.ConfigureSmtpSettingsByDefault();
  54. TestLibrary.SettingHelper.ConfigureUsersSettings(false, true, false, null, null, false, false, null);
  55. User user = null;
  56. try
  57. {
  58. //user = TestLibrary.UserHelper.AddUser(new UserSettings() { UserName = "v-haiyin", Email = "v-haiyin@microsoft.com" });
  59. user = TestLibrary.UserHelper.AddUser(new UserSettings() { UserName = TestLibrary.Consts.strLostPwdUserNameOf163, Email = TestLibrary.Consts.strLostPwdUserEmailOf163 });
  60. }
  61. catch (Exception ex)
  62. {
  63. if (!ex.ToString().Contains("Timed out after 30000ms"))
  64. Assert.IsTrue(false, "Bug#18035,Mybe Can not save UsersSettings, fail to save checkbox status." + ex.ToString());
  65. }
  66. TestLibrary.UserHelper.LogOff();
  67. selenium.Click("link=Sign In");
  68. selenium.WaitForPageToLoad("6000");
  69. selenium.Click("link=exact:Lost your Password?");
  70. System.Threading.Thread.Sleep(3000);
  71. selenium.Type("//input[@id='username']", "");
  72. selenium.Click("//button[@type='submit']");
  73. System.Threading.Thread.Sleep(3000);
  74. Assert.IsTrue(selenium.IsTextPresent("Invalid username or E-mail"),"Bug#18079 Maybe miss error messages.");
  75. selenium.Type("id=username", "w@");
  76. selenium.Click("//button[@type='submit']");
  77. System.Threading.Thread.Sleep(3000);
  78. Assert.IsFalse(selenium.IsTextPresent("Check your e-mail for the confirmation link"),"Bug#18079 Maybe when email/username is invalid,need prompt error messages.");
  79. //then, don't need to validate email
  80. }
  81. }
  82. }