Skip to content

Commit ef6acb0

Browse files
committed
test: 更新单元测试
1 parent 25570d9 commit ef6acb0

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/BootstrapBlazor/Services/CacheManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ public static string GetUniqueName(Assembly assembly)
246246
return assembly.IsCollectible
247247
? $"{assembly.GetName().Name}-{assembly.GetHashCode()}"
248248
: $"{assembly.GetName().Name}";
249-
}
250-
);
249+
});
251250
}
252251

253252
#endregion

test/UnitTest/Components/BootstrapModuleComponentBaseTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public void InvokeVoidAsync_Ok()
1818
}
1919

2020
[Fact]
21-
public void InvokeAsync_Ok()
21+
public async Task InvokeAsync_Ok()
2222
{
2323
var cut = Context.RenderComponent<MockObjectReferenceComponent>();
24-
cut.InvokeAsync(() => cut.Instance.InvokeAsyncTest());
24+
await cut.InvokeAsync(() => cut.Instance.InvokeAsyncTest());
2525
Assert.True(cut.Instance.InvokeRunner);
2626
}
2727

@@ -42,18 +42,17 @@ public async Task InvokeVoidAsyncTest()
4242
}
4343
}
4444

45-
[JSModuleAutoLoader("mock.js", JSObjectReference = true, AutoInvokeDispose = true, AutoInvokeInit = true)]
4645
class MockObjectReferenceComponent : Select<string>
4746
{
4847
public bool InvokeRunner { get; set; }
4948

5049
public async Task InvokeAsyncTest()
5150
{
52-
await base.InvokeAsync<string>(Id);
53-
await base.InvokeAsync<string>(Id, TimeSpan.FromMinutes(1));
51+
await InvokeAsync<string>(Id);
52+
await InvokeAsync<string>(Id, TimeSpan.FromMinutes(1));
5453

5554
using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(1000);
56-
await base.InvokeAsync<string>(Id, cancellationTokenSource.Token);
55+
await InvokeAsync<string>(Id, cancellationTokenSource.Token);
5756

5857
InvokeRunner = true;
5958
}

test/UnitTest/Extensions/AssemblyExtensionsTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public class AssemblyExtensionsTest
1313
[Fact]
1414
public void GetUniqueName_Ok()
1515
{
16+
var sc = new ServiceCollection();
17+
sc.AddBootstrapBlazor();
18+
19+
var provider = sc.BuildServiceProvider();
20+
var cacheManager = provider.GetRequiredService<ICacheManager>();
21+
cacheManager.GetStartTime();
22+
1623
var type = Type.GetType("BootstrapBlazor.Components.AssemblyExtensions, BootstrapBlazor");
1724
Assert.NotNull(type);
1825

test/UnitTest/Services/ConnectionHubTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public class ConnectionHubTest
1313
[Fact]
1414
public async Task Callback_Ok()
1515
{
16+
var sc = new ServiceCollection();
17+
sc.AddBootstrapBlazor();
18+
19+
var provider = sc.BuildServiceProvider();
20+
var cacheManager = provider.GetRequiredService<ICacheManager>();
21+
cacheManager.GetStartTime();
22+
1623
var context = new TestContext();
1724
context.JSInterop.Mode = JSRuntimeMode.Loose;
1825
context.Services.AddBootstrapBlazor();

0 commit comments

Comments
 (0)