diff options
Diffstat (limited to 'code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers')
| -rw-r--r-- | code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs b/code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs index 080fa9f..de316de 100644 --- a/code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs +++ b/code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs @@ -7,7 +7,6 @@ using Program = IOL.GreatOffice.Api.Program; namespace IOL.GreatOffice.IntegrationTests.Helpers; -// ReSharper disable once ClassNeverInstantiated.Global public class WebServerFixture : IAsyncLifetime, IDisposable { private readonly WebApplication Host; @@ -15,30 +14,35 @@ public class WebServerFixture : IAsyncLifetime, IDisposable public IBrowser Browser { get; private set; } public string BaseUrl { get; } = $"https://localhost:{GetRandomUnusedPort()}"; - public WebServerFixture() { + public WebServerFixture() + { Host = Program.CreateWebApplication(Program.CreateAppBuilder(default)); } - public async Task InitializeAsync() { + public async Task InitializeAsync() + { Playwright = await Microsoft.Playwright.Playwright.CreateAsync(); Browser = await Playwright.Chromium.LaunchAsync(); await Host.StartAsync(); } - public async Task DisposeAsync() { + public async Task DisposeAsync() + { await Host.StopAsync(); await Host.DisposeAsync(); Playwright?.Dispose(); } - public void Dispose() { + public void Dispose() + { Host.StopAsync(); Host.DisposeAsync(); Playwright?.Dispose(); GC.SuppressFinalize(this); } - private static int GetRandomUnusedPort() { + private static int GetRandomUnusedPort() + { var listener = new TcpListener(IPAddress.Any, 0); listener.Start(); var port = ((IPEndPoint)listener.LocalEndpoint).Port; |
