Here is the rule I am trying to test:
RuleFor(m => m.Groups)
.SetValidator(new MustContainAtLeastOne<AuthGroup>())
.OverridePropertyName("Roles");
Test:
validator.ShouldHaveValidationErrorFor(m => m.Groups,new List<AuthGroup>());
Question:
It fails when I have .OverridePropertyName("Roles")
but when I remove it, test passes.
Is this an issue with Fluent Validation Validator class?
Post a issue on the project site:
https://github.com/JeremySkinner/FluentValidation/issues/359
I believe the TestHelper compares the name of the property specified in the lambda expression to the property name in the generated error message. In this case, because you've overridden the property name they won't match and so the assertion fails. You'll need to perform the assertion manually rather than using the TestHelper in this situation.