Skip to content

Commit

Permalink
test(Display): update test for nullable value (#4656)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgoZhang authored Nov 14, 2024
1 parent 4b33dae commit a8fa755
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions test/UnitTest/Components/DateTimeRangeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ await cut.InvokeAsync(() =>
//Assert.True(input.ClassList.Contains("datetime"));
//Assert.True(DateTime.TryParseExact(input.GetAttribute("Value"), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var _));

// timeformat
// time format
//cut.SetParametersAndRender(pb =>
//{
// pb.Add(a => a.TimeFormat, "hhmmss");
Expand Down Expand Up @@ -332,7 +332,7 @@ public void ValueChanged_Ok()
var cut = Context.RenderComponent<DateTimeRange>(builder =>
{
builder.Add(a => a.Value, new DateTimeRangeValue { Start = DateTime.Now, End = DateTime.Now.AddDays(30) });
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<DateTimeRangeValue>(this, v => { value = v; }));
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<DateTimeRangeValue?>(this, v => { value = v; }));
});
cut.FindAll(".is-confirm").First(s => s.TextContent == "清空").Click();
}
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Components/InputNumberTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public override Task SetParametersAsync(ParameterView parameters)
return Task.CompletedTask;
}

protected override string? InternalFormat(string value)
protected override string? InternalFormat(string? value)
{
return base.InternalFormat(value);
}
Expand Down
4 changes: 2 additions & 2 deletions test/UnitTest/Components/InputTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task OnInput_Ok()
{
builder.Add(a => a.Value, foo.Name);
builder.Add(a => a.UseInputEvent, true);
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v =>
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v =>
{
foo.Name = v;
}));
Expand Down Expand Up @@ -336,7 +336,7 @@ public void OnValueChanged_Ok()
var cut = Context.RenderComponent<BootstrapInput<string>>(builder =>
{
builder.Add(a => a.Value, foo.Name);
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v =>
builder.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v =>
{
foo.Name = v;
}));
Expand Down
8 changes: 4 additions & 4 deletions test/UnitTest/Components/SelectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public void SelectItem_Ok()
new("2", "Text2"),
});
pb.Add(a => a.Value, v);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem>(this, i => v = i));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem?>(this, i => v = i));
});
Assert.Equal("2", cut.Instance.Value.Value);

Expand Down Expand Up @@ -771,7 +771,7 @@ public void IsVirtualize_BindValue()
{
pb.Add(a => a.Value, value);
pb.Add(a => a.IsVirtualize, true);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem>(this, new Action<SelectedItem>(item =>
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<SelectedItem?>(this, new Action<SelectedItem?>(item =>
{
value = item;
})));
Expand Down Expand Up @@ -812,13 +812,13 @@ public void IsVirtualize_BindValue()
[Fact]
public void IsVirtualize_DefaultVirtualizeItemText()
{
string value = "3";
string? value = "3";
var cut = Context.RenderComponent<Select<string>>(pb =>
{
pb.Add(a => a.IsVirtualize, true);
pb.Add(a => a.DefaultVirtualizeItemText, "Test 3");
pb.Add(a => a.Value, value);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, new Action<string>(item =>
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, new Action<string?>(item =>
{
value = item;
})));
Expand Down
4 changes: 2 additions & 2 deletions test/UnitTest/Components/SelectTreeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task Value_Null()
{
c.Add(p => p.Items, BindItems);
c.Add(p => p.Value, model.Name);
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string>(this, s => model.Name = s));
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string?>(this, s => model.Name = s));
c.Add(p => p.ValueExpression, Utility.GenerateValueExpression(model, nameof(model.Name), typeof(string)));
});
});
Expand All @@ -89,7 +89,7 @@ public async Task Valid_Ok()
{
c.Add(p => p.Items, BindItems);
c.Add(p => p.Value, model.Name);
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string>(this, s => model.Name = s));
c.Add(p => p.ValueChanged, EventCallback.Factory.Create<string?>(this, s => model.Name = s));
c.Add(p => p.ValueExpression, Utility.GenerateValueExpression(model, nameof(model.Name), typeof(string)));
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/UnitTest/Components/TransferTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TransferTest : BootstrapBlazorTestBase
[Fact]
public void Items_Ok()
{
// 未设置 Itms 为空
// 未设置 Items 为空
var cut = Context.RenderComponent<Transfer<string>>();
cut.Contains("class=\"transfer\"");

Expand Down Expand Up @@ -136,7 +136,7 @@ public async Task ValidateForm_Ok()
pb.AddChildContent<Transfer<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(Context, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(Context, v => foo.Name = v));
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
pb.Add(a => a.Items, new List<SelectedItem>()
{
Expand Down Expand Up @@ -187,7 +187,7 @@ public void MaxMin_Ok()
var cut = Context.RenderComponent<Transfer<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
pb.Add(a => a.ValueExpression, Utility.GenerateValueExpression(foo, "Name", typeof(string)));
pb.Add(a => a.Items, new List<SelectedItem>()
{
Expand Down
10 changes: 5 additions & 5 deletions test/UnitTest/Components/ValidateFormTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task Validate_Ok()
pb.AddChildContent<BootstrapInput<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
});
});
Expand Down Expand Up @@ -78,7 +78,7 @@ public void OnFieldValueChanged_Ok()
pb.AddChildContent<BootstrapInput<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
});
});
Expand All @@ -105,7 +105,7 @@ public void ValidateAllProperties_Ok()
pb.AddChildContent<BootstrapInput<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
});
});
Expand All @@ -125,7 +125,7 @@ public void ShowRequiredMark_Ok()
pb.AddChildContent<BootstrapInput<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
});
});
Expand All @@ -149,7 +149,7 @@ public void ShowLabel_Ok()
pb.AddChildContent<BootstrapInput<string>>(pb =>
{
pb.Add(a => a.Value, foo.Name);
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string>(this, v => foo.Name = v));
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
});
});
Expand Down

0 comments on commit a8fa755

Please sign in to comment.