Skip to content

Commit 51d4bb1

Browse files
committed
test: 增加单元测试
1 parent d8a9a9d commit 51d4bb1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/UnitTest/Components/EditorFormTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,30 @@ public async Task LookupService_Ok()
480480
Assert.Equal("LookupService-Test-1-async", select.Instance.Items.First().Text);
481481
}
482482

483+
[Fact]
484+
public void Lookup_Ok()
485+
{
486+
var foo = new Foo();
487+
var lookup = new List<SelectedItem>() { new("v1", "test1"), new("v2", "test2") };
488+
var cut = Context.RenderComponent<EditorForm<Foo>>(pb =>
489+
{
490+
pb.Add(a => a.Model, foo);
491+
pb.Add(a => a.AutoGenerateAllItem, false);
492+
pb.Add(a => a.FieldItems, f => builder =>
493+
{
494+
var index = 0;
495+
builder.OpenComponent<EditorItem<Foo, string>>(index++);
496+
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Field), f.Name);
497+
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.FieldExpression), Utility.GenerateValueExpression(foo, nameof(Foo.Name), typeof(string)));
498+
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Text), "Test-Text");
499+
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Lookup), lookup);
500+
builder.CloseComponent();
501+
});
502+
});
503+
var select = cut.FindComponent<Select<string>>();
504+
Assert.Equal(2, select.Instance.Items.Count());
505+
}
506+
483507
[Theory]
484508
[InlineData(true)]
485509
[InlineData(false)]

0 commit comments

Comments
 (0)