You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Automation.Test/AutomationTest.cs

78 lines
2.0 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using FluentAssertions;
using NLog;
using NLog.Config;
using NLog.Targets;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
namespace NzbDrone.Automation.Test
{
[TestFixture]
[AutomationTest]
public abstract class AutomationTest
{
private NzbDroneRunner _runner;
protected RemoteWebDriver driver;
public AutomationTest()
{
new StartupArguments();
LogManager.Configuration = new LoggingConfiguration();
var consoleTarget = new ConsoleTarget { Layout = "${level}: ${message} ${exception}" };
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
}
[TestFixtureSetUp]
public void SmokeTestSetup()
{
driver = new FirefoxDriver();
_runner = new NzbDroneRunner();
_runner.KillAll();
_runner.Start();
driver.Url = "http://localhost:8989";
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(d => d.FindElement(By.Id("x-toolbar")));
GetPageErrors().Should().BeEmpty();
}
protected IEnumerable<string> GetPageErrors()
{
return driver.FindElements(By.CssSelector("#errors div"))
.Select(e => e.Text);
}
[TestFixtureTearDown]
public void SmokeTestTearDown()
{
_runner.KillAll();
driver.Quit();
}
[TearDown]
public void AutomationTearDown()
{
Thread.Sleep(2000);
GetPageErrors().Should().BeEmpty();
}
}
}