mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 21:50:05 +08:00
!2249 test(#I4NWBH): add unit test for AmbiguousMatchException
* chore: bump version to 6.1.1 * test: 增加二义性异常单元测试 * fix: 增加数据类型判断 * fix: 兼容子类 new 复写父类属性情况 * test: 增加子类使用 new 重写父类属性单元测试 * fix: 修复子类使用 new 导致属性二义性异常 * refactor: 重构代码
This commit is contained in:
parent
5f777a2b06
commit
132677f9d0
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>6.1.1-beta12</Version>
|
||||
<Version>6.1.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
@ -499,6 +499,28 @@ namespace UnitTest.Components
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Required_AmbiguousMatch()
|
||||
{
|
||||
var model = new Cat();
|
||||
var rules = new List<IValidator>
|
||||
{
|
||||
new FormItemValidator(new RequiredAttribute())
|
||||
};
|
||||
var cut = Context.RenderComponent<ValidateForm>(builder =>
|
||||
{
|
||||
builder.Add(v => v.Model, model);
|
||||
builder.AddChildContent<MockValidate<int>>(pb =>
|
||||
{
|
||||
pb.Add(v => v.Value, model.Foo);
|
||||
pb.Add(v => v.ValueExpression, Utility.GenerateValueExpression(model, nameof(Cat.Foo), typeof(int)));
|
||||
pb.Add(v => v.ValidateRules, rules);
|
||||
});
|
||||
});
|
||||
|
||||
// 不会报错 AmbiguousMatchException
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TooltipHost_Ok()
|
||||
{
|
||||
@ -532,5 +554,16 @@ namespace UnitTest.Components
|
||||
OnValidate(true);
|
||||
}
|
||||
}
|
||||
|
||||
class Dummy
|
||||
{
|
||||
public virtual string? Foo { get; set; }
|
||||
}
|
||||
|
||||
class Cat : Dummy
|
||||
{
|
||||
[Required]
|
||||
public new int Foo { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user