From 854dedead3a3ed987997a0132f527db73b65b0ac Mon Sep 17 00:00:00 2001 From: ivar Date: Sat, 11 Nov 2023 22:10:42 +0100 Subject: Div more changes --- .../Helpers/WebServerFixture.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs') 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; -- cgit v1.3