using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Prevu
{
[TestClass]
public class Users : BaseTest
{
#region Initialization & CleanUp
[ClassInitialize]
public static void ClassInitialize(TestContext TestContext)
{
BaseTest.ClassInitialize(TestContext);
}
[ClassCleanup]
public static void ClassCleanup()
{
BaseTest.ClassCleanup();
}
#endregion Initialization & CleanUp
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout * 5)]
[TestProperty("Create User", "1. Open the Users page
2. Click 'Add User' button
3. Fill the following fields:
User Name
First Name
Last Name
Email Address
Phone Number
4. Select Roles:
Delivery Admin
Product Owner
QA Engineer
5. Click Save
6.Find created user and check stored data")]
public void CreateUser()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("u{0}", tempId);
string firstName = "User";
string email = string.Format("e{0}@gmail.com", tempId);
string phone = "+1 (900) 768-9056";
string[] roles = new string[3] { "Delivery Admin", "Product Owner", "QA Engineer" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
Assert.IsTrue(usersPage.CheckUser(id, userName, firstName, tempId, email, phone, roles));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout * 5)]
[TestProperty("Activate User Account", "1. Open the Users page
2. Click 'Add User' button
3. Fill the following fields:
User Name
First Name
Last Name
Email Address
Phone Number
4. Select Roles:
Development Manager
Infrastructure Manager
5. Click Save
6. Log off
7. Check the user mailbox and receive letter
8. Open the Users account activation URL
9. Set up new password
10. Log in as new created user")]
public void ActivateUserAccount()
{
IgnoreExistingEmailMessages("iniphiqa", "iniphiqa753");
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("u{0}", tempId);
string firstName = "User";
string email = string.Format("iniphiqa+{0}@gmail.com", tempId);
string phone = "+1 (961) 5368-7542";
string[] roles = new string[2] { "Development Manager", "Infrastructure Manager" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
Assert.IsTrue(loginPage.SignOut());
string mailBody = "";
Assert.IsTrue(CheckEmailMessage("iniphiqa", "iniphiqa753",
"support@prevuplan.com", email, "Activate your Prevu account", new string[4] {
string.Format("Hello, {0}.", userName),
"Please activate your Prevu account by clicking the following link:",
string.Format("{0}Account/Activate/?userId", driver.Domain),
"Thank you!" },
out mailBody));
Assert.IsNotNull(mailBody);
mailBody = mailBody.Replace("userId", "userId=");
string userId = driver.Subs(mailBody, "Account/Activate/?userId=", ".");
Assert.IsFalse(string.IsNullOrEmpty(userId));
Assert.IsTrue(activateUserAccountPage.ActivateUserAccount(userId, userName, email, string.Format("qa{0}", tempId)));
Assert.IsTrue(loginPage.CheckLoggedInUser(userName));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout)]
[TestProperty("Delete User", "1. Find a user
2. Click Delete button
3. Check warning message:
You are about to delete the User Name.Are you sure you want to delete it?
4. Click Delete button
5. Make sure that user is deleted")]
public void DeleteUser()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("d{0}", tempId);
string firstName = "User";
string email = string.Format("d{0}@gmail.com", tempId);
string phone = "+1 (902) 657-9312";
string[] roles = new string[1] { "Director" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
Assert.IsTrue(usersPage.DeleteUser(id, userName));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout)]
[TestProperty("Edit User", "1. Find a user
2. Click Edit button
3. Change the following fields:
User Name
First Name
Last Name
Email Address
Phone Number
Add new roles
4. Click Save
5. Open the Users details
6. Check edited field values")]
public void EditUser()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("d{0}", tempId);
string firstName = "User";
string email = string.Format("u{0}@gmail.com", tempId);
string phone = "+1 (902) 657-9312";
string[] roles = new string[1] { "Director" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
userName = string.Format("d{0}E", tempId);
firstName = "UserE";
string lastName = string.Format("{0}E", tempId);
email = string.Format("u{0}E@gmail.com", tempId);
phone = "+1 (999) 009-0021";
roles = new string[3] { "Delivery Admin", "Product Owner", "QA Engineer" };
Assert.IsTrue(usersPage.EditUser(id, userName, firstName, lastName, email, phone, roles));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout)]
[TestProperty("Reset User Password", "1. Find a user
2. Click 'Reset Password' button
3. Check the notification message:
Email with reset password link has been sent to user's email.
4. Log off
5. Check mailbox and receive mail message
6. Check mail message:
Hello, < username >
You can restore your Prevu account by clicking the following link: Account / RestorePassword /? token = < token >.
Thank you!
7. Open the password restore URL
8. Check the Restore Password form:
Enter new password
9. Input new password to Password field
10. Input new password to Password Confirmation field
11. Click Submit
12. Check the notification message:
Password has been successfully changed.
13. Click 'Back to login page'
14. Input username to Username
15. Input new password to Passwors
16. Click Sign In")]
public void ResetUserPassword()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
Assert.IsTrue(usersPage.ResetUserPassword("iniphiqa@gmail.com"));
Assert.IsTrue(usersPage.OpenUsers());
Assert.IsTrue(loginPage.SignOut());
string mailBody = "";
Assert.IsTrue(CheckEmailMessage("iniphiqa", "iniphiqa753",
"support@prevuplan.com", "iniphiqa@gmail.com", "Restore password", new string[5] {
"Hello, gdonavan.",
"You can restore your Prevu account by clicking the following link:",
string.Format("{0}Account/RestorePassword/?token", driver.Domain),
"The link can only be used for 24 hours.",
"Thank you!" },
out mailBody));
Assert.IsNotNull(mailBody);
mailBody = mailBody.Replace("token", "token=");
string token = driver.Subs(mailBody, "Account/RestorePassword/?token=", ".");
Assert.IsFalse(string.IsNullOrEmpty(token));
Assert.IsTrue(forgotPasswordPage.OpenResetPassword(token, "Enter new password"));
string newPassword = string.Format("qa{0}", tempId);
Assert.IsTrue(forgotPasswordPage.ResetPassword(newPassword));
Assert.IsTrue(loginPage.SignIn("gdonavan", newPassword));
}
}
}