45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using System;
|
|
using IntegrationTests.Helpers;
|
|
using IntegrationTests.Properties;
|
|
using NUnit.Framework;
|
|
using OpenQA.Selenium;
|
|
using OpenQA.Selenium.Support.UI;
|
|
|
|
namespace IntegrationTests.Users
|
|
{
|
|
[TestFixture]
|
|
public class UserTests : BaseIntegrationTest
|
|
{
|
|
[Test]
|
|
public void Login_AdminLoggedIn()
|
|
{
|
|
Logoff();
|
|
|
|
WebDriver.FindElement(By.Id("username_id")).SendKeys(Settings.Default.AdminUser);
|
|
WebDriver.FindElement(By.Id("password_id")).SendKeys(Settings.Default.AdminPwd);
|
|
WebDriver.FindElement(By.Id("btnSubmit")).Click();
|
|
Browser.WaitForAjax(WebDriver);
|
|
var usernameLink = WebDriver.FindElement(By.Id("aUserName"));
|
|
|
|
Assert.IsNotNull(usernameLink, "Cannot find a link with logged-in username.");
|
|
Assert.AreEqual("Hello " + Settings.Default.AdminUser + "!", usernameLink.Text, "Link text does not match expected value.");
|
|
}
|
|
|
|
[Test]
|
|
public void Login_AdminLoggedInFailed()
|
|
{
|
|
Logoff();
|
|
|
|
WebDriver.Url = Settings.Default.WebSiteUrl + "Account/Login";
|
|
WebDriver.Navigate();
|
|
WebDriver.FindElement(By.Id("username_id")).SendKeys("AnyIncorrectName");
|
|
WebDriver.FindElement(By.Id("password_id")).SendKeys("anypassword");
|
|
WebDriver.FindElement(By.Id("btnSubmit")).Click();
|
|
Browser.WaitForAjax(WebDriver);
|
|
var validationLink = WebDriver.FindElement(By.ClassName("validation-summary-errors"));
|
|
|
|
Assert.IsNotNull(validationLink, "An error occurred while validating username and password");
|
|
}
|
|
}
|
|
}
|