Skip to content

Commit 1a0a935

Browse files
committed
test: 补充单元测试
1 parent 340dda5 commit 1a0a935

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/UnitTest/Localization/JsonStringLocalizerTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,20 @@ public void GetResourcePrefix_Ok()
330330
Assert.Equal("test", result.Value);
331331
}
332332

333+
[Fact]
334+
public void CreateResourceManagerStringLocalizer_UseBaseNameWhenTypeNameIsNull()
335+
{
336+
var factory = Context.Services.GetRequiredService<IStringLocalizerFactory>();
337+
var mi = factory.GetType().GetMethod("CreateResourceManagerStringLocalizer", BindingFlags.NonPublic | BindingFlags.Instance)!;
338+
339+
var baseName = typeof(Foo).FullName!;
340+
var localizer = Assert.IsType<IStringLocalizer>(mi.Invoke(factory, [typeof(Foo).Assembly, baseName]), exactMatch: false);
341+
var result = localizer["not-found-key"];
342+
343+
Assert.True(result.ResourceNotFound);
344+
Assert.Equal(baseName, result.SearchedLocation);
345+
}
346+
333347
private static readonly string[] localizationConfigure = ["zh-CN.json"];
334348

335349
[Fact]

0 commit comments

Comments
 (0)