Skip to content

Commit d4b53b7

Browse files
authored
Use IAsyncLifetime for async initialization/disposal (#2135)
1 parent c2f90eb commit d4b53b7

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/PuppeteerSharp.Tests/PuppeteerLoaderFixture.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
using PuppeteerSharp.TestServer;
22
using System;
33
using System.Threading.Tasks;
4+
using Xunit;
45

56
namespace PuppeteerSharp.Tests
67
{
7-
public sealed class PuppeteerLoaderFixture : IDisposable
8+
public sealed class PuppeteerLoaderFixture : IAsyncLifetime
89
{
910
public static SimpleServer Server { get; private set; }
1011
public static SimpleServer HttpsServer { get; private set; }
1112

12-
public PuppeteerLoaderFixture()
13-
{
14-
SetupAsync().GetAwaiter().GetResult();
15-
}
13+
Task IAsyncLifetime.InitializeAsync() => SetupAsync();
1614

17-
public void Dispose()
18-
{
19-
Task.WaitAll(Server.StopAsync(), HttpsServer.StopAsync());
20-
}
15+
Task IAsyncLifetime.DisposeAsync() => Task.WhenAll(Server.StopAsync(), HttpsServer.StopAsync());
2116

2217
private async Task SetupAsync()
2318
{

0 commit comments

Comments
 (0)