I have this rule for validate that a property has a valid value depending on a list of allowed values in another property.
model.RuleFor(c => c)
.Must(c => string.IsNullOrEmpty(c.CurrentValue) || (!string.IsNullOrEmpty(c.CurrentValue) && c.AllowedValues.Contains(c.CurrentValue)))
That works fine, but I want to create a unit test, but always fail. I think is because of the RuleFor is not at an specific property but the object itself.
this.validator.ShouldNotHaveValidationErrorFor(c => c.CurrentValue, this.model);
How can I improve the validator or the test?