Skip to content

Commit a8fa755

Browse files
authored
test(Display): update test for nullable value (#4656)
1 parent 4b33dae commit a8fa755

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

test/UnitTest/Components/DateTimeRangeTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ await cut.InvokeAsync(() =>
285285
//Assert.True(input.ClassList.Contains("datetime"));
286286
//Assert.True(DateTime.TryParseExact(input.GetAttribute("Value"), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var _));
287287

288-
// timeformat
288+
// time format
289289
//cut.SetParametersAndRender(pb =>
290290
//{
291291
// pb.Add(a => a.TimeFormat, "hhmmss");
@@ -332,7 +332,7 @@ public void ValueChanged_Ok()
332332
var cut = Context.RenderComponent<DateTimeRange>(builder =>
333333
{
334334
builder.Add(a => a.Value, new DateTimeRangeValue { Start = DateTime.Now, End = DateTime.Now.AddDays(30) });
335-
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<DateTimeRangeValue>(this, v => { value = v; }));
335+
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<DateTimeRangeValue?>(this, v => { value = v; }));
336336
});
337337
cut.FindAll(".is-confirm").First(s => s.TextContent == "清空").Click();
338338
}

test/UnitTest/Components/InputNumberTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public override Task SetParametersAsync(ParameterView parameters)
233233
return Task.CompletedTask;
234234
}
235235

236-
protected override string? InternalFormat(string value)
236+
protected override string? InternalFormat(string? value)
237237
{
238238
return base.InternalFormat(value);
239239
}

test/UnitTest/Components/InputTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public async Task OnInput_Ok()
7777
{
7878
builder.Add(a => a.Value, foo.Name);
7979
builder.Add(a => a.UseInputEvent, true);
80-
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v =>
80+
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v =>
8181
{
8282
foo.Name = v;
8383
}));
@@ -336,7 +336,7 @@ public void OnValueChanged_Ok()
336336
var cut = Context.RenderComponent<BootstrapInput<string>>(builder =>
337337
{
338338
builder.Add(a => a.Value, foo.Name);
339-
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v =>
339+
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v =>
340340
{
341341
foo.Name = v;
342342
}));

test/UnitTest/Components/SelectTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public void SelectItem_Ok()
436436
new("2", "Text2"),
437437
});
438438
pb.Add(a => a.Value, v);
439-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem>(this, i => v = i));
439+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem?>(this, i => v = i));
440440
});
441441
Assert.Equal("2", cut.Instance.Value.Value);
442442

@@ -771,7 +771,7 @@ public void IsVirtualize_BindValue()
771771
{
772772
pb.Add(a => a.Value, value);
773773
pb.Add(a => a.IsVirtualize, true);
774-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem>(this, new Action<SelectedItem>(item =>
774+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem?>(this, new Action<SelectedItem?>(item =>
775775
{
776776
value = item;
777777
})));
@@ -812,13 +812,13 @@ public void IsVirtualize_BindValue()
812812
[Fact]
813813
public void IsVirtualize_DefaultVirtualizeItemText()
814814
{
815-
string value = "3";
815+
string? value = "3";
816816
var cut = Context.RenderComponent<Select<string>>(pb =>
817817
{
818818
pb.Add(a => a.IsVirtualize, true);
819819
pb.Add(a => a.DefaultVirtualizeItemText, "Test 3");
820820
pb.Add(a => a.Value, value);
821-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, new Action<string>(item =>
821+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, new Action<string?>(item =>
822822
{
823823
value = item;
824824
})));

test/UnitTest/Components/SelectTreeTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task Value_Null()
6969
{
7070
c.Add(p => p.Items, BindItems);
7171
c.Add(p => p.Value, model.Name);
72-
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string>(this, s => model.Name = s));
72+
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string?>(this, s => model.Name = s));
7373
c.Add(p => p.ValueExpression, Utility.GenerateValueExpression(model, nameof(model.Name), typeof(string)));
7474
});
7575
});
@@ -89,7 +89,7 @@ public async Task Valid_Ok()
8989
{
9090
c.Add(p => p.Items, BindItems);
9191
c.Add(p => p.Value, model.Name);
92-
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string>(this, s => model.Name = s));
92+
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string?>(this, s => model.Name = s));
9393
c.Add(p => p.ValueExpression, Utility.GenerateValueExpression(model, nameof(model.Name), typeof(string)));
9494
});
9595
});

test/UnitTest/Components/TransferTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class TransferTest : BootstrapBlazorTestBase
1010
[Fact]
1111
public void Items_Ok()
1212
{
13-
// 未设置 Itms 为空
13+
// 未设置 Items 为空
1414
var cut = Context.RenderComponent<Transfer<string>>();
1515
cut.Contains("class=\"transfer\"");
1616

@@ -136,7 +136,7 @@ public async Task ValidateForm_Ok()
136136
pb.AddChildContent<Transfer<string>>(pb =>
137137
{
138138
pb.Add(a => a.Value, foo.Name);
139-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(Context, v => foo.Name = v));
139+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(Context, v => foo.Name = v));
140140
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
141141
pb.Add(a => a.Items, new List<SelectedItem>()
142142
{
@@ -187,7 +187,7 @@ public void MaxMin_Ok()
187187
var cut = Context.RenderComponent<Transfer<string>>(pb =>
188188
{
189189
pb.Add(a => a.Value, foo.Name);
190-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
190+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
191191
pb.Add(a => a.ValueExpression, Utility.GenerateValueExpression(foo, "Name", typeof(string)));
192192
pb.Add(a => a.Items, new List<SelectedItem>()
193193
{

test/UnitTest/Components/ValidateFormTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task Validate_Ok()
4747
pb.AddChildContent<BootstrapInput<string>>(pb =>
4848
{
4949
pb.Add(a => a.Value, foo.Name);
50-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
50+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
5151
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
5252
});
5353
});
@@ -78,7 +78,7 @@ public void OnFieldValueChanged_Ok()
7878
pb.AddChildContent<BootstrapInput<string>>(pb =>
7979
{
8080
pb.Add(a => a.Value, foo.Name);
81-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
81+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
8282
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
8383
});
8484
});
@@ -105,7 +105,7 @@ public void ValidateAllProperties_Ok()
105105
pb.AddChildContent<BootstrapInput<string>>(pb =>
106106
{
107107
pb.Add(a => a.Value, foo.Name);
108-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
108+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
109109
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
110110
});
111111
});
@@ -125,7 +125,7 @@ public void ShowRequiredMark_Ok()
125125
pb.AddChildContent<BootstrapInput<string>>(pb =>
126126
{
127127
pb.Add(a => a.Value, foo.Name);
128-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
128+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
129129
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
130130
});
131131
});
@@ -149,7 +149,7 @@ public void ShowLabel_Ok()
149149
pb.AddChildContent<BootstrapInput<string>>(pb =>
150150
{
151151
pb.Add(a => a.Value, foo.Name);
152-
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
152+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
153153
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
154154
});
155155
});

0 commit comments

Comments
 (0)