!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:
Argo 2021-12-23 17:27:37 +00:00
parent 5f777a2b06
commit 132677f9d0
2 changed files with 34 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor"> <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup> <PropertyGroup>
<Version>6.1.1-beta12</Version> <Version>6.1.1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@ -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] [Fact]
public void TooltipHost_Ok() public void TooltipHost_Ok()
{ {
@ -532,5 +554,16 @@ namespace UnitTest.Components
OnValidate(true); OnValidate(true);
} }
} }
class Dummy
{
public virtual string? Foo { get; set; }
}
class Cat : Dummy
{
[Required]
public new int Foo { get; set; }
}
} }
} }