Skip to content

Commit

Permalink
test: 更新单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgoZhang committed Dec 19, 2024
1 parent e22894a commit 6db218d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 43 deletions.
41 changes: 0 additions & 41 deletions test/UnitTest/Components/TableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5161,47 +5161,6 @@ public void TableColumn_Align()
Assert.Equal("table-cell center", css);
}

[Fact]
public void TableColumn_Ignore()
{
var items = new List<MockComplexFoo>([
new() { Name = "Test1", Foo = new() { Id = 1, Name = "Test_1" } },
new() { Name = "Test2", Foo = new() { Id = 2, Name = "Test_2" } },
new() { Name = "Test3", Foo = new() { Id = 3, Name = "Test_3" } },
]);
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
{
pb.AddChildContent<Table<MockComplexFoo>>(pb =>
{
pb.Add(a => a.Items, items);
pb.Add(a => a.AutoGenerateColumns, true);
pb.Add(a => a.RenderMode, TableRenderMode.Table);

pb.Add(a => a.TableColumns, foo => builder =>
{
builder.OpenComponent<TableColumn<MockComplexFoo, int>>(0);
builder.AddAttribute(1, "Field", 0);
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Foo.Id", typeof(int)));
builder.CloseComponent();

builder.OpenComponent<TableColumn<MockComplexFoo, string>>(0);
builder.AddAttribute(1, "Field", "Test");
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Foo.Name", typeof(string)));
builder.CloseComponent();

builder.OpenComponent<TableColumn<MockComplexFoo, string>>(0);
builder.AddAttribute(1, "Field", "Test");
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Foo.Address", typeof(string)));
builder.CloseComponent();
});
});
});

// 自动生成 2 列 手动 Id 列忽略 Name, Address 列追加
var table = cut.FindComponent<Table<MockComplexFoo>>();
Assert.Equal(5, table.Instance.Columns.Count);
}

[Fact]
public void TableColumn_ComplexObject()
{
Expand Down
8 changes: 6 additions & 2 deletions test/UnitTest/Utils/UtilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,12 @@ public void Format_Format()
[Fact]
public void GetTableColumns_Ok()
{
var cols = Utility.GetTableColumns<Dog>().ToList();
Assert.Equal(2, cols.Count);
var columns = new InternalTableColumn[]
{
new("Name3", typeof(string)),
};
var cols = Utility.GetTableColumns<Dog>(columns).ToList();
Assert.Equal(3, cols.Count);
}

[Fact]
Expand Down

0 comments on commit 6db218d

Please sign in to comment.