mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-06 18:52:27 +00:00
The Great Formatting of 2022
This commit is contained in:
parent
59cc7f02fb
commit
35f50f5f8c
162 changed files with 6609 additions and 6809 deletions
|
@ -7,44 +7,43 @@ using OpenQA.Selenium;
|
|||
using OpenQA.Selenium.Chrome;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests;
|
||||
|
||||
[Collection(nameof(LighthouseWebTest))]
|
||||
public class LighthouseWebTest : IDisposable
|
||||
{
|
||||
[Collection(nameof(LighthouseWebTest))]
|
||||
public class LighthouseWebTest : IDisposable
|
||||
public readonly string BaseAddress;
|
||||
|
||||
public readonly IWebDriver Driver;
|
||||
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestStartup>().UseWebRoot("StaticFiles").Build();
|
||||
|
||||
public LighthouseWebTest()
|
||||
{
|
||||
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestStartup>().UseWebRoot("StaticFiles").Build();
|
||||
public readonly string BaseAddress;
|
||||
this.WebHost.Start();
|
||||
|
||||
public readonly IWebDriver Driver;
|
||||
IServerAddressesFeature? serverAddressesFeature = this.WebHost.ServerFeatures.Get<IServerAddressesFeature>();
|
||||
if (serverAddressesFeature == null) throw new ArgumentNullException();
|
||||
|
||||
public LighthouseWebTest()
|
||||
this.BaseAddress = serverAddressesFeature.Addresses.First();
|
||||
|
||||
ChromeOptions chromeOptions = new();
|
||||
if (Convert.ToBoolean(Environment.GetEnvironmentVariable("CI") ?? "false"))
|
||||
{
|
||||
this.WebHost.Start();
|
||||
|
||||
IServerAddressesFeature? serverAddressesFeature = WebHost.ServerFeatures.Get<IServerAddressesFeature>();
|
||||
if (serverAddressesFeature == null) throw new ArgumentNullException();
|
||||
|
||||
this.BaseAddress = serverAddressesFeature.Addresses.First();
|
||||
|
||||
ChromeOptions chromeOptions = new();
|
||||
if (Convert.ToBoolean(Environment.GetEnvironmentVariable("CI") ?? "false"))
|
||||
{
|
||||
chromeOptions.AddArgument("headless");
|
||||
chromeOptions.AddArgument("no-sandbox");
|
||||
chromeOptions.AddArgument("disable-dev-shm-usage");
|
||||
Console.WriteLine("We are in a CI environment, so chrome headless mode has been enabled.");
|
||||
}
|
||||
|
||||
this.Driver = new ChromeDriver(chromeOptions);
|
||||
chromeOptions.AddArgument("headless");
|
||||
chromeOptions.AddArgument("no-sandbox");
|
||||
chromeOptions.AddArgument("disable-dev-shm-usage");
|
||||
Console.WriteLine("We are in a CI environment, so chrome headless mode has been enabled.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Driver.Close();
|
||||
this.Driver.Dispose();
|
||||
this.WebHost.Dispose();
|
||||
this.Driver = new ChromeDriver(chromeOptions);
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
this.Driver.Close();
|
||||
this.Driver.Dispose();
|
||||
this.WebHost.Dispose();
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue