mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-24 14:11:29 +00:00
Massive organization of classes and namespaces
This commit is contained in:
parent
3e7a5910cd
commit
c345eeebb9
218 changed files with 468 additions and 342 deletions
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Startup;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Chrome;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests.Tests;
|
||||
|
||||
[Collection(nameof(LighthouseWebTest))]
|
||||
public class LighthouseWebTest : IDisposable
|
||||
{
|
||||
public readonly string BaseAddress;
|
||||
|
||||
public readonly IWebDriver Driver;
|
||||
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<WebsiteTestStartup>().UseWebRoot("StaticFiles").Build();
|
||||
|
||||
public LighthouseWebTest()
|
||||
{
|
||||
this.WebHost.Start();
|
||||
|
||||
IServerAddressesFeature? serverAddressesFeature = this.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);
|
||||
}
|
||||
|
||||
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