178 lines
12 KiB
C#
178 lines
12 KiB
C#
using System;
|
|
using System.Linq;
|
|
using IntegrationTests.Helpers;
|
|
using IntegrationTests.Models;
|
|
using IntegrationTests.Properties;
|
|
using NUnit.Framework;
|
|
using OpenQA.Selenium;
|
|
using OpenQA.Selenium.Support.UI;
|
|
|
|
namespace IntegrationTests.Projects
|
|
{
|
|
[TestFixture]
|
|
public class CreateProjectTests : BaseIntegrationTest
|
|
{
|
|
[Test]
|
|
public void CreateProject()
|
|
{
|
|
//TODO: Learn how to wait/verify JS values
|
|
//new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)).Until(
|
|
// webDriver => ((IJavaScriptExecutor)webDriver).ExecuteScript("return isNaN(DataForChart)").Equals(false));
|
|
//WaitForPageLoad(WebDriver, 5);
|
|
Browser.WaitForAjax(WebDriver);
|
|
|
|
WebDriver.Url = Settings.Default.WebSiteUrl + "Project/Edit";
|
|
WebDriver.Navigate();
|
|
Browser.WaitForAjax(WebDriver);
|
|
|
|
WebDriver.FindElement(By.Id("IDDDD")).SendKeys("My First Project");
|
|
WebDriver.FindElement(By.Id("Number")).SendKeys("1345");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "StatusId", "ead7ac04-de87-4104-a9a7-52b97ab7a4bf"))
|
|
Assert.Fail("Cannot find an option with value 'ead7ac04-de87-4104-a9a7-52b97ab7a4bf' in select#StatusId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "TypeId", "a437a456-7e95-4429-a904-2becfe92b448"))
|
|
Assert.Fail("Cannot find an option with value 'a437a456-7e95-4429-a904-2becfe92b448' in select#TypeId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "ClientId", "07211465-ed91-46f3-9029-4807df8b1efe"))
|
|
Assert.Fail("Cannot find an option with value '07211465-ed91-46f3-9029-4807df8b1efe' in select#ClientId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "CompanyId", "6a7125d9-a742-4831-9cd8-178bf1be1cfa"))
|
|
Assert.Fail("Cannot find an option with value '6a7125d9-a742-4831-9cd8-178bf1be1cfa' in select#CompanyId.");
|
|
WebDriver.FindElement(By.Id("input-color")).SendKeys("#bc2525");
|
|
WebDriver.FindElement(By.Id("Priority")).SendKeys("15");
|
|
WebDriver.FindElement(By.Id("Details")).SendKeys("Here is some details for you");
|
|
var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
|
|
wait.Until(webDriver => ((IJavaScriptExecutor)webDriver).ExecuteScript("val.slider('value', 75); return true;").Equals(true));
|
|
new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)).Until(driver => true);
|
|
WebDriver.FindElement(By.Id("btnsave")).Click();
|
|
wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
|
|
var tr = wait.Until(driver => driver.FindElement(By.CssSelector("#prjcts tbody tr")));
|
|
//WaitForAjax();
|
|
|
|
Console.WriteLine("start assert");
|
|
Assert.AreEqual(Settings.Default.WebSiteUrl + "Project", WebDriver.Url);
|
|
using (var db = new EnvisageTestContext())
|
|
{
|
|
var project = db.Projects.FirstOrDefault();
|
|
Assert.IsNotNull(project, "The project was not created");
|
|
Assert.AreEqual("My First Project", project.Name, "The project name has been set incorrectly");
|
|
Assert.AreEqual("1345", project.ProjectNumber, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("ead7ac04-de87-4104-a9a7-52b97ab7a4bf"), project.StatusId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("a437a456-7e95-4429-a904-2becfe92b448"), project.TypeId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("07211465-ed91-46f3-9029-4807df8b1efe"), project.ClientId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("6a7125d9-a742-4831-9cd8-178bf1be1cfa"), project.CompanyId, "The project number has been set incorrectly");
|
|
Assert.AreEqual("bc2525", project.Color, "The project number has been set incorrectly");
|
|
Assert.AreEqual(15, project.Priority, "The project number has been set incorrectly");
|
|
Assert.AreEqual("Here is some details for you", project.Details, "The project number has been set incorrectly");
|
|
Assert.AreEqual(0.75m, project.Probability, "The project number has been set incorrectly");
|
|
}
|
|
Console.WriteLine("end assert");
|
|
}
|
|
|
|
[Test]
|
|
public void CreateProject2()
|
|
{
|
|
//TODO: Learn how to wait/verify JS values
|
|
//new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)).Until(
|
|
// webDriver => ((IJavaScriptExecutor)webDriver).ExecuteScript("return isNaN(DataForChart)").Equals(false));
|
|
//WaitForPageLoad(WebDriver, 5);
|
|
Browser.WaitForAjax(WebDriver);
|
|
|
|
WebDriver.Url = Settings.Default.WebSiteUrl + "Project/Edit";
|
|
WebDriver.Navigate();
|
|
Browser.WaitForAjax(WebDriver);
|
|
|
|
WebDriver.FindElement(By.Id("IDDDD")).SendKeys("My First Project");
|
|
WebDriver.FindElement(By.Id("Number")).SendKeys("1345");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "StatusId", "ead7ac04-de87-4104-a9a7-52b97ab7a4bf"))
|
|
Assert.Fail("Cannot find an option with value 'ead7ac04-de87-4104-a9a7-52b97ab7a4bf' in select#StatusId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "TypeId", "a437a456-7e95-4429-a904-2becfe92b448"))
|
|
Assert.Fail("Cannot find an option with value 'a437a456-7e95-4429-a904-2becfe92b448' in select#TypeId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "ClientId", "07211465-ed91-46f3-9029-4807df8b1efe"))
|
|
Assert.Fail("Cannot find an option with value '07211465-ed91-46f3-9029-4807df8b1efe' in select#ClientId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "CompanyId", "6a7125d9-a742-4831-9cd8-178bf1be1cfa"))
|
|
Assert.Fail("Cannot find an option with value '6a7125d9-a742-4831-9cd8-178bf1be1cfa' in select#CompanyId.");
|
|
WebDriver.FindElement(By.Id("input-color")).SendKeys("#bc2525");
|
|
WebDriver.FindElement(By.Id("Priority")).SendKeys("15");
|
|
WebDriver.FindElement(By.Id("Details")).SendKeys("Here is some details for you");
|
|
var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
|
|
wait.Until(webDriver => ((IJavaScriptExecutor)webDriver).ExecuteScript("val.slider('value', 75); return true;").Equals(true));
|
|
new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)).Until(driver => true);
|
|
WebDriver.FindElement(By.Id("btnsave")).Click();
|
|
wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
|
|
var tr = wait.Until(driver => driver.FindElement(By.CssSelector("#prjcts tbody tr")));
|
|
//WaitForAjax();
|
|
|
|
Console.WriteLine("start assert");
|
|
Assert.AreEqual(Settings.Default.WebSiteUrl + "Project", WebDriver.Url);
|
|
using (var db = new EnvisageTestContext())
|
|
{
|
|
var project = db.Projects.FirstOrDefault();
|
|
Assert.IsNotNull(project, "The project was not created");
|
|
Assert.AreEqual("My First Project", project.Name, "The project name has been set incorrectly");
|
|
Assert.AreEqual("1345", project.ProjectNumber, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("ead7ac04-de87-4104-a9a7-52b97ab7a4bf"), project.StatusId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("a437a456-7e95-4429-a904-2becfe92b448"), project.TypeId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("07211465-ed91-46f3-9029-4807df8b1efe"), project.ClientId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("6a7125d9-a742-4831-9cd8-178bf1be1cfa"), project.CompanyId, "The project number has been set incorrectly");
|
|
Assert.AreEqual("bc2525", project.Color, "The project number has been set incorrectly");
|
|
Assert.AreEqual(15, project.Priority, "The project number has been set incorrectly");
|
|
Assert.AreEqual("Here is some details for you", project.Details, "The project number has been set incorrectly");
|
|
Assert.AreEqual(0.75m, project.Probability, "The project number has been set incorrectly");
|
|
}
|
|
Console.WriteLine("end assert");
|
|
}
|
|
|
|
[Test]
|
|
public void CreateProject1()
|
|
{
|
|
//TODO: Learn how to wait/verify JS values
|
|
//new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)).Until(
|
|
// webDriver => ((IJavaScriptExecutor)webDriver).ExecuteScript("return isNaN(DataForChart)").Equals(false));
|
|
//WaitForPageLoad(WebDriver, 5);
|
|
Browser.WaitForAjax(WebDriver);
|
|
|
|
WebDriver.Url = Settings.Default.WebSiteUrl + "Project/Edit";
|
|
WebDriver.Navigate();
|
|
Browser.WaitForAjax(WebDriver);
|
|
|
|
WebDriver.FindElement(By.Id("IDDDD")).SendKeys("My First Project");
|
|
WebDriver.FindElement(By.Id("Number")).SendKeys("1345");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "StatusId", "ead7ac04-de87-4104-a9a7-52b97ab7a4bf"))
|
|
Assert.Fail("Cannot find an option with value 'ead7ac04-de87-4104-a9a7-52b97ab7a4bf' in select#StatusId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "TypeId", "a437a456-7e95-4429-a904-2becfe92b448"))
|
|
Assert.Fail("Cannot find an option with value 'a437a456-7e95-4429-a904-2becfe92b448' in select#TypeId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "ClientId", "07211465-ed91-46f3-9029-4807df8b1efe"))
|
|
Assert.Fail("Cannot find an option with value '07211465-ed91-46f3-9029-4807df8b1efe' in select#ClientId.");
|
|
if (!Browser.SelectOptionByValue(WebDriver, "CompanyId", "6a7125d9-a742-4831-9cd8-178bf1be1cfa"))
|
|
Assert.Fail("Cannot find an option with value '6a7125d9-a742-4831-9cd8-178bf1be1cfa' in select#CompanyId.");
|
|
WebDriver.FindElement(By.Id("input-color")).SendKeys("#bc2525");
|
|
WebDriver.FindElement(By.Id("Priority")).SendKeys("15");
|
|
WebDriver.FindElement(By.Id("Details")).SendKeys("Here is some details for you");
|
|
var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
|
|
wait.Until(webDriver => ((IJavaScriptExecutor)webDriver).ExecuteScript("val.slider('value', 75); return true;").Equals(true));
|
|
new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)).Until(driver => true);
|
|
WebDriver.FindElement(By.Id("btnsave")).Click();
|
|
wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
|
|
var tr = wait.Until(driver => driver.FindElement(By.CssSelector("#prjcts tbody tr")));
|
|
//WaitForAjax();
|
|
|
|
Console.WriteLine("start assert");
|
|
Assert.AreEqual(Settings.Default.WebSiteUrl + "Project", WebDriver.Url);
|
|
using (var db = new EnvisageTestContext())
|
|
{
|
|
var project = db.Projects.FirstOrDefault();
|
|
Assert.IsNotNull(project, "The project was not created");
|
|
Assert.AreEqual("My First Project", project.Name, "The project name has been set incorrectly");
|
|
Assert.AreEqual("1345", project.ProjectNumber, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("ead7ac04-de87-4104-a9a7-52b97ab7a4bf"), project.StatusId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("a437a456-7e95-4429-a904-2becfe92b448"), project.TypeId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("07211465-ed91-46f3-9029-4807df8b1efe"), project.ClientId, "The project number has been set incorrectly");
|
|
Assert.AreEqual(Guid.Parse("6a7125d9-a742-4831-9cd8-178bf1be1cfa"), project.CompanyId, "The project number has been set incorrectly");
|
|
Assert.AreEqual("bc2525", project.Color, "The project number has been set incorrectly");
|
|
Assert.AreEqual(15, project.Priority, "The project number has been set incorrectly");
|
|
Assert.AreEqual("Here is some details for you", project.Details, "The project number has been set incorrectly");
|
|
Assert.AreEqual(0.75m, project.Probability, "The project number has been set incorrectly");
|
|
}
|
|
Console.WriteLine("end assert");
|
|
}
|
|
}
|
|
}
|