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 | |
| parent | 7e874b9aecabe22a731d582505cadd87b699d159 (diff) | |
| download | greatoffice-854dedead3a3ed987997a0132f527db73b65b0ac.tar.xz greatoffice-854dedead3a3ed987997a0132f527db73b65b0ac.zip | |
Div more changes
Diffstat (limited to 'code/api/tests/IOL.GreatOffice.IntegrationTests')
| -rw-r--r-- | code/api/tests/IOL.GreatOffice.IntegrationTests/ApplicationTests/LoginPageTests.cs | 6 | ||||
| -rw-r--r-- | code/api/tests/IOL.GreatOffice.IntegrationTests/Helpers/WebServerFixture.cs | 16 |
2 files changed, 14 insertions, 8 deletions
diff --git a/code/api/tests/IOL.GreatOffice.IntegrationTests/ApplicationTests/LoginPageTests.cs b/code/api/tests/IOL.GreatOffice.IntegrationTests/ApplicationTests/LoginPageTests.cs index 10525fd..71578eb 100644 --- a/code/api/tests/IOL.GreatOffice.IntegrationTests/ApplicationTests/LoginPageTests.cs +++ b/code/api/tests/IOL.GreatOffice.IntegrationTests/ApplicationTests/LoginPageTests.cs @@ -7,12 +7,14 @@ public class LoginPageTests : IClassFixture<WebServerFixture> { private readonly WebServerFixture _fixture; - public LoginPageTests(WebServerFixture fixture) { + public LoginPageTests(WebServerFixture fixture) + { _fixture = fixture; } [Fact] - public async Task LoginPageTestsRenders() { + public async Task LoginPageTestsRenders() + { var page = await _fixture.Browser.NewPageAsync(); await page.GotoAsync(_fixture.BaseUrl); 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; |
