-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align per-test and per-class disposal
- Loading branch information
Showing
4 changed files
with
11 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,27 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace PuppeteerSharp.Tests | ||
{ | ||
public class PuppeteerBrowserBaseTest : PuppeteerBaseTest, IDisposable, IAsyncDisposable | ||
public class PuppeteerBrowserBaseTest : PuppeteerBaseTest | ||
{ | ||
protected IBrowser Browser { get; set; } | ||
|
||
protected LaunchOptions DefaultOptions { get; set; } | ||
|
||
[SetUp] | ||
public virtual async Task InitializeAsync() | ||
public async Task InitializeAsync() | ||
=> Browser = await Puppeteer.LaunchAsync( | ||
DefaultOptions ?? TestConstants.DefaultBrowserOptions(), | ||
TestConstants.LoggerFactory); | ||
|
||
[TearDown] | ||
public virtual async Task DisposeAsync() | ||
public async Task TearDownAsync() | ||
{ | ||
if (Browser is not null) | ||
{ | ||
await Browser.CloseAsync(); | ||
await Browser.DisposeAsync(); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
protected virtual void Dispose(bool disposing) => _ = DisposeAsync(); | ||
|
||
ValueTask IAsyncDisposable.DisposeAsync() | ||
{ | ||
GC.SuppressFinalize(this); | ||
return Browser.DisposeAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters