The Great Formatting of 2022

This commit is contained in:
jvyden 2022-01-18 23:09:02 -05:00
parent 59cc7f02fb
commit 35f50f5f8c
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
162 changed files with 6609 additions and 6809 deletions

View file

@ -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);
}
}