diff options
| author | ivar <i@oiee.no> | 2023-11-11 22:10:42 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2023-11-11 22:10:42 +0100 |
| commit | 854dedead3a3ed987997a0132f527db73b65b0ac (patch) | |
| tree | 982dddd8b1dc4c819147912222ec2b38dd3b671e /code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs | |
| parent | 7e874b9aecabe22a731d582505cadd87b699d159 (diff) | |
| download | greatoffice-854dedead3a3ed987997a0132f527db73b65b0ac.tar.xz greatoffice-854dedead3a3ed987997a0132f527db73b65b0ac.zip | |
Div more changes
Diffstat (limited to 'code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs')
| -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; |
