Skip to content

Commit 91d0151

Browse files
authored
test(Localizer): update GetJsonStringByTypeName_UseKeyWhenValueIsNull test (#7088)
* doc: 更新注释 * refactor: 更新单元测试
1 parent 746d0c9 commit 91d0151

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/BootstrapBlazor/Localization/Json/JsonLocalizationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
@@ -44,7 +44,7 @@ public class JsonLocalizationOptions : LocalizationOptions
4444
public bool IgnoreLocalizerMissing { get; set; }
4545

4646
/// <summary>
47-
/// 获得/设置 如果 Value 值为 null 时使用 Key 代替 默认 false 触发异常
47+
/// 获得/设置 如果 Value 值为 null 时使用 Key 代替 默认 false
4848
/// </summary>
4949
public bool UseKeyWhenValueIsNull { get; set; }
5050

test/UnitTest/Locales/en-US.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"BootstrapBlazor.Server.Data.Foo": {
33
"Name": "Name",
44
"DateTime": "DateTime",
@@ -28,6 +28,6 @@
2828
},
2929
"UnitTest.Utils.UtilityTest": {
3030
"Test-Null": null,
31-
"Test-Key:": ""
31+
"Test-Key": ""
3232
}
3333
}

test/UnitTest/Utils/UtilityTest.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
@@ -393,14 +393,19 @@ public void GetJsonStringByTypeName_UseKeyWhenValueIsNull()
393393

394394
var test1 = items.FirstOrDefault(i => i.Name == "Test-Null");
395395
Assert.NotNull(test1);
396+
397+
#if NET9_0
398+
Assert.Equal("", test1.Value);
399+
#elif NET10_0_OR_GREATER
396400
Assert.Equal("Test-Null", test1.Value);
401+
#endif
397402

398403
var test2 = items.FirstOrDefault(i => i.Name == "Test-Key");
399404
Assert.NotNull(test2);
400-
Assert.Equal("Test-Key", test2.Value);
405+
Assert.Equal("", test2.Value);
401406

402407
option.UseKeyWhenValueIsNull = false;
403-
items = Utility.GetJsonStringByTypeName(option, this.GetType().Assembly, "UnitTest.Utils.UtilityTest", "en-US", true);
408+
items = Utility.GetJsonStringByTypeName(option, GetType().Assembly, "UnitTest.Utils.UtilityTest", "en-US", true);
404409

405410
test1 = items.FirstOrDefault(i => i.Name == "Test-Null");
406411
Assert.NotNull(test1);

0 commit comments

Comments
 (0)