Lidarr/src/NzbDrone.Automation.Test/AutomationTest.cs

73 lines
1.9 KiB
C#
Raw Normal View History

2013-11-20 00:42:17 +00:00
using System.Collections.Generic;
2013-11-12 03:25:54 +00:00
using System.Linq;
using FluentAssertions;
using NLog;
using NLog.Config;
using NLog.Targets;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
2013-11-12 03:25:54 +00:00
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
2013-11-12 06:18:57 +00:00
using OpenQA.Selenium.Remote;
2013-11-12 03:25:54 +00:00
namespace NzbDrone.Automation.Test
{
[TestFixture]
[AutomationTest]
public abstract class AutomationTest
{
private NzbDroneRunner _runner;
2013-11-12 06:18:57 +00:00
protected RemoteWebDriver driver;
2013-11-12 03:25:54 +00:00
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));
}
2013-11-12 06:18:57 +00:00
[TestFixtureSetUp]
2013-11-12 03:25:54 +00:00
public void SmokeTestSetup()
{
driver = new FirefoxDriver();
_runner = new NzbDroneRunner();
_runner.KillAll();
_runner.Start();
driver.Url = "http://localhost:8989";
var page = new PageBase(driver);
page.WaitForNoSpinner();
2013-11-12 03:25:54 +00:00
GetPageErrors().Should().BeEmpty();
}
protected IEnumerable<string> GetPageErrors()
{
return driver.FindElements(By.CssSelector("#errors div"))
.Select(e => e.Text);
}
2013-11-12 06:18:57 +00:00
[TestFixtureTearDown]
2013-11-12 03:25:54 +00:00
public void SmokeTestTearDown()
{
_runner.KillAll();
2013-11-12 06:18:57 +00:00
driver.Quit();
2013-11-12 03:25:54 +00:00
}
2013-11-12 06:18:57 +00:00
[TearDown]
public void AutomationTearDown()
2013-11-12 03:25:54 +00:00
{
2013-11-12 06:18:57 +00:00
GetPageErrors().Should().BeEmpty();
2013-11-12 03:25:54 +00:00
}
}
}