Skip to content

Commit d942d6d

Browse files
committed
test: 更新单元测试
1 parent 84e8c84 commit d942d6d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/UnitTest/Utils/UtilityTest.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public void GetJsonStringByTypeName_Ok()
380380
}
381381

382382
[Fact]
383-
public void GetJsonStringByTypeName_Exception()
383+
public void GetJsonStringByTypeName_UseKeyWhenValueIsNull()
384384
{
385385
// improve code coverage
386386
var option = Context.Services.GetRequiredService<IOptions<JsonLocalizationOptions>>().Value;
@@ -394,6 +394,17 @@ public void GetJsonStringByTypeName_Exception()
394394
var test2 = items.FirstOrDefault(i => i.Name == "Test-Key");
395395
Assert.NotNull(test2);
396396
Assert.Equal("Test-Key", test2.Value);
397+
398+
option.UseKeyWhenValueIsNull = false;
399+
items = Utility.GetJsonStringByTypeName(option, this.GetType().Assembly, "UnitTest.Utils.UtilityTest", "en-US", true);
400+
401+
test1 = items.FirstOrDefault(i => i.Name == "Test-Null");
402+
Assert.NotNull(test1);
403+
Assert.Equal("", test1.Value);
404+
405+
test2 = items.FirstOrDefault(i => i.Name == "Test-Key");
406+
Assert.NotNull(test2);
407+
Assert.Equal("", test2.Value);
397408
}
398409

399410
private class MockDynamicObject : IDynamicObject

0 commit comments

Comments
 (0)