mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2025-12-06 07:28:50 +08:00
test(TestBase): move IDispose interface to TestBase (#7134)
* test: 移动接口到基类 * test: 消除警告信息
This commit is contained in:
@@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace UnitTest.Core;
|
||||
|
||||
public class BootstrapBlazorTestBase : TestBase, IDisposable
|
||||
public class BootstrapBlazorTestBase : TestBase
|
||||
{
|
||||
protected ICacheManager Cache { get; }
|
||||
|
||||
@@ -38,12 +38,6 @@ public class BootstrapBlazorTestBase : TestBase, IDisposable
|
||||
services.AddConfiguration();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_ = Context.DisposeAsync();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
class FooLookupService : LookupServiceBase
|
||||
{
|
||||
public override IEnumerable<SelectedItem>? GetItemsByKey(string? key, object? data)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace UnitTest.Core;
|
||||
|
||||
public class TestBase
|
||||
public class TestBase : IDisposable
|
||||
{
|
||||
protected BunitContext Context { get; }
|
||||
|
||||
@@ -16,4 +16,13 @@ public class TestBase
|
||||
|
||||
Context.Services.AddMockEnvironment();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
#pragma warning disable CA2012
|
||||
// 由于 bUnit 2.0 继承了 IAsyncDisposable 接口,因此此处调用 DisposeAsync 方法
|
||||
Context.DisposeAsync();
|
||||
#pragma warning restore CA2012
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user