Skip to content

Commit 2eeea13

Browse files
committed
test: 更新单元测试
1 parent 18ab730 commit 2eeea13

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/UnitTest/Services/ConfigureIconMapperOptionsTest.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

66
using Microsoft.Extensions.Options;
7+
using System.Collections.Frozen;
78

89
namespace UnitTest.Services;
910

@@ -33,11 +34,12 @@ public void ConfigureIconMapperOptions_Ok()
3334
context.Services.AddOptionsMonitor<IconThemeOptions>();
3435
context.Services.ConfigureIconThemeOptions(options =>
3536
{
36-
options.ThemeKey = "mock";
37-
options.Icons["mock"] = new()
37+
var icons = new Dictionary<ComponentIcons, string>()
3838
{
3939
{ ComponentIcons.AnchorLinkIcon, "mdi mdi-link-variant" }
4040
};
41+
options.TryAddIcons("mock", icons.ToFrozenDictionary());
42+
options.ThemeKey = "mock";
4143
});
4244

4345
var iconService = context.Services.GetRequiredService<IIconTheme>();
@@ -57,11 +59,11 @@ internal class MockIconTheme(IOptions<IconThemeOptions> options) : IIconTheme
5759
/// <inheritdoc/>
5860
/// </summary>
5961
/// <returns></returns>
60-
public Dictionary<ComponentIcons, string> GetIcons()
62+
public FrozenDictionary<ComponentIcons, string> GetIcons()
6163
{
6264
if (!Options.Value.Icons.TryGetValue(Options.Value.ThemeKey, out var icons))
6365
{
64-
icons = [];
66+
icons = FrozenDictionary<ComponentIcons, string>.Empty;
6567
}
6668
return icons;
6769
}

0 commit comments

Comments
 (0)