Skip to content

Commit 6db218d

Browse files
committed
test: 更新单元测试
1 parent e22894a commit 6db218d

File tree

2 files changed

+6
-43
lines changed

2 files changed

+6
-43
lines changed

test/UnitTest/Components/TableTest.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5161,47 +5161,6 @@ public void TableColumn_Align()
51615161
Assert.Equal("table-cell center", css);
51625162
}
51635163

5164-
[Fact]
5165-
public void TableColumn_Ignore()
5166-
{
5167-
var items = new List<MockComplexFoo>([
5168-
new() { Name = "Test1", Foo = new() { Id = 1, Name = "Test_1" } },
5169-
new() { Name = "Test2", Foo = new() { Id = 2, Name = "Test_2" } },
5170-
new() { Name = "Test3", Foo = new() { Id = 3, Name = "Test_3" } },
5171-
]);
5172-
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
5173-
{
5174-
pb.AddChildContent<Table<MockComplexFoo>>(pb =>
5175-
{
5176-
pb.Add(a => a.Items, items);
5177-
pb.Add(a => a.AutoGenerateColumns, true);
5178-
pb.Add(a => a.RenderMode, TableRenderMode.Table);
5179-
5180-
pb.Add(a => a.TableColumns, foo => builder =>
5181-
{
5182-
builder.OpenComponent<TableColumn<MockComplexFoo, int>>(0);
5183-
builder.AddAttribute(1, "Field", 0);
5184-
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Foo.Id", typeof(int)));
5185-
builder.CloseComponent();
5186-
5187-
builder.OpenComponent<TableColumn<MockComplexFoo, string>>(0);
5188-
builder.AddAttribute(1, "Field", "Test");
5189-
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Foo.Name", typeof(string)));
5190-
builder.CloseComponent();
5191-
5192-
builder.OpenComponent<TableColumn<MockComplexFoo, string>>(0);
5193-
builder.AddAttribute(1, "Field", "Test");
5194-
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Foo.Address", typeof(string)));
5195-
builder.CloseComponent();
5196-
});
5197-
});
5198-
});
5199-
5200-
// 自动生成 2 列 手动 Id 列忽略 Name, Address 列追加
5201-
var table = cut.FindComponent<Table<MockComplexFoo>>();
5202-
Assert.Equal(5, table.Instance.Columns.Count);
5203-
}
5204-
52055164
[Fact]
52065165
public void TableColumn_ComplexObject()
52075166
{

test/UnitTest/Utils/UtilityTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,12 @@ public void Format_Format()
696696
[Fact]
697697
public void GetTableColumns_Ok()
698698
{
699-
var cols = Utility.GetTableColumns<Dog>().ToList();
700-
Assert.Equal(2, cols.Count);
699+
var columns = new InternalTableColumn[]
700+
{
701+
new("Name3", typeof(string)),
702+
};
703+
var cols = Utility.GetTableColumns<Dog>(columns).ToList();
704+
Assert.Equal(3, cols.Count);
701705
}
702706

703707
[Fact]

0 commit comments

Comments
 (0)