test(TestBase): move IDispose interface to TestBase (#7134)

* test: 移动接口到基类

* test: 消除警告信息
This commit is contained in:
Argo Zhang
2025-11-17 09:28:41 +08:00
committed by GitHub
parent f95a8609c9
commit 52058b6966
2 changed files with 11 additions and 8 deletions

View File

@@ -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)

View File

@@ -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);
}
}