-
-
Notifications
You must be signed in to change notification settings - Fork 381
Expand file tree
/
Copy pathInternalTableColumnTest.cs
More file actions
91 lines (86 loc) · 3.76 KB
/
InternalTableColumnTest.cs
File metadata and controls
91 lines (86 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
namespace UnitTest.Components;
public class InternalTableColumnTest
{
[Fact]
public void InternalTableColumn_Ok()
{
var typeName = "BootstrapBlazor.Components.InternalTableColumn, BootstrapBlazor";
var type = Type.GetType(typeName);
var instance = Activator.CreateInstance(type!, "Name", typeof(string), "Name");
SetValue("Sortable", true);
SetValue("DefaultSort", true);
SetValue("DefaultSortOrder", SortOrder.Asc);
SetValue("Filterable", true);
SetValue("Searchable", true);
SetValue("Width", 100);
SetValue("Fixed", true);
SetValue("TextWrap", true);
SetValue("TextEllipsis", true);
SetValue("SkipValidate", true);
SetValue("IsReadonlyWhenAdd", true);
SetValue("IsReadonlyWhenEdit", true);
SetValue("ShowLabelTooltip", true);
SetValue("CssClass", "css-test");
SetValue("ShownWithBreakPoint", BreakPoint.Small);
SetValue("Template", new RenderFragment<object?>(context => builder =>
{
builder.AddContent(0, context);
}));
SetValue("SearchTemplate", new RenderFragment<object?>(context => builder =>
{
builder.AddContent(0, context);
}));
SetValue("FilterTemplate", new RenderFragment(builder =>
{
builder.AddContent(0, "test");
}));
SetValue("HeaderTemplate", new RenderFragment<ITableColumn>(col => builder =>
{
builder.AddContent(0, col.GetFieldName());
}));
SetValue("ToolboxTemplate", new RenderFragment<ITableColumn>(col => builder =>
{
builder.AddContent(0, "test");
}));
SetValue("Filter", new TableFilter());
SetValue("FormatString", "test");
SetValue("Formatter", new Func<object?, Task<string>>(val =>
{
return Task.FromResult("Test");
}));
SetValue("Align", Alignment.Left);
SetValue("ShowTips", true);
SetValue("Readonly", true);
SetValue("Step", "1");
SetValue("Rows", 1);
SetValue("ComponentType", typeof(string));
SetValue("Order", 1);
SetValue("Lookup", new SelectedItem[] { new("test", "Test") });
SetValue("ShowSearchWhenSelect", true);
SetValue("IsPopover", true);
SetValue("LookupStringComparison", StringComparison.Ordinal);
SetValue("LookupServiceKey", "Test");
SetValue("OnCellRender", new Action<TableCellArgs>(args => { }));
SetValue("ValidateRules", new List<IValidator> { new RequiredValidator() });
SetValue("GroupName", "Test");
SetValue("GroupOrder", 1);
SetValue("ShowCopyColumn", true);
SetValue("HeaderTextWrap", true);
SetValue("ShowHeaderTooltip", true);
SetValue("HeaderTextTooltip", "Test");
SetValue("HeaderTextEllipsis", true);
SetValue("IsMarkupString", true);
SetValue("GetTooltipTextCallback", new Func<object, Task<string?>>(_ => Task.FromResult((string?)"")));
SetValue("CustomSearch", new Func<ITableColumn, string?, SearchFilterAction>((_, _) => new SearchFilterAction("test", "test")));
SetValue("Required", true);
SetValue("RequiredErrorMessage", "test");
SetValue("IsRequiredWhenAdd", true);
SetValue("IsRequiredWhenEdit", true);
SetValue("LookupService", null);
void SetValue(string propertyName, object? val) => type!.GetProperty(propertyName)!.SetValue(instance, val);
}
}