diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 46b5ff3f9b1..b921a79d2aa 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.2.0-beta01 + 9.2.0-beta02 diff --git a/src/BootstrapBlazor/Components/Display/Display.razor.cs b/src/BootstrapBlazor/Components/Display/Display.razor.cs index edf186f47ed..712780bc332 100644 --- a/src/BootstrapBlazor/Components/Display/Display.razor.cs +++ b/src/BootstrapBlazor/Components/Display/Display.razor.cs @@ -128,7 +128,7 @@ private async Task FormatText([DisallowNull] TValue value) private async Task FormatValueString() { - string? ret = Value?.ToString() ?? string.Empty; + var ret = Value?.ToString(); var lookup = await GetLookup(); if (lookup != null) { @@ -137,11 +137,11 @@ private async Task FormatValueString() return ret ?? string.Empty; } - private Func? _arrayConvertoString; + private Func? _arrayConvertToString; private string ArrayConvertToString(TValue value) { - _arrayConvertoString ??= LambdaExtensions.ArrayConvertToStringLambda(TypeResolver).Compile(); - return _arrayConvertoString(value); + _arrayConvertToString ??= LambdaExtensions.ArrayConvertToStringLambda(TypeResolver).Compile(); + return _arrayConvertToString(value); } private static Func? _enumerableConvertToString; diff --git a/test/UnitTest/Components/DisplayTest.cs b/test/UnitTest/Components/DisplayTest.cs index 3f2f6b7cc2c..0059aa7f9de 100644 --- a/test/UnitTest/Components/DisplayTest.cs +++ b/test/UnitTest/Components/DisplayTest.cs @@ -59,6 +59,14 @@ public async Task LookupService_Ok() }); await Task.Delay(20); Assert.Contains("Test1,Test2", cut.Markup); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.LookupServiceKey, null); + pb.Add(a => a.Lookup, new List { new("v1", "Test3"), new("v2", "Test4") }); + }); + await Task.Delay(20); + Assert.Contains("Test3,Test4", cut.Markup); } [Fact] diff --git a/test/UnitTest/Components/EditorFormTest.cs b/test/UnitTest/Components/EditorFormTest.cs index 949717bd9bb..36203771e51 100644 --- a/test/UnitTest/Components/EditorFormTest.cs +++ b/test/UnitTest/Components/EditorFormTest.cs @@ -480,6 +480,30 @@ public async Task LookupService_Ok() Assert.Equal("LookupService-Test-1-async", select.Instance.Items.First().Text); } + [Fact] + public void Lookup_Ok() + { + var foo = new Foo(); + var lookup = new List() { new("v1", "test1"), new("v2", "test2") }; + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.Model, foo); + pb.Add(a => a.AutoGenerateAllItem, false); + pb.Add(a => a.FieldItems, f => builder => + { + var index = 0; + builder.OpenComponent>(index++); + builder.AddAttribute(index++, nameof(EditorItem.Field), f.Name); + builder.AddAttribute(index++, nameof(EditorItem.FieldExpression), Utility.GenerateValueExpression(foo, nameof(Foo.Name), typeof(string))); + builder.AddAttribute(index++, nameof(EditorItem.Text), "Test-Text"); + builder.AddAttribute(index++, nameof(EditorItem.Lookup), lookup); + builder.CloseComponent(); + }); + }); + var select = cut.FindComponent>(); + Assert.Equal(2, select.Instance.Items.Count()); + } + [Theory] [InlineData(true)] [InlineData(false)]