Fluent验证单元使用When子句测试SetValidator

时间:2017-05-18 09:11:54

标签: c# unit-testing fluentvalidation

我试图根据属性值对设置子验证器的能力进行单元测试。

RuleFor(x => x.Property2)
    .SetValidator(new Property2Validator())
    .When(x => x.Property1 == 1);

在我的单元测试中,我有以下断言

validatorUnderTest.ShouldHaveChildValidator(x => x.Property2, typeof(Property2Validator));

然而,这总是失败,因为验证器仅在验证发生时附加。如果我删除'何时'它条款很好。

0 个答案:

没有答案