Howdy,
Ive been battling with this issue which I originally thought may have been to do with polymorphism/inheritance affecting my validation but ive narrowed it to this...
Here is the class structure..
public class Employee {
[ObjectValidator(Ruleset = "A")]
public EmployeeName Name { get; set; }
public Employee()
{
Name = new EmployeeName();
}
}
public class EmployeeName
{
[StringLengthValidator(1,20,Ruleset = "A")]
public string First { get; set; }
public string Last { get; set; }
public EmployeeName()
{
First = string.Empty;
Last = string.Empty;
}
}
The test:
[TestFixture]
public class ObjectValidationWithRulesets
{
[Test]
public void wont_validate_with_a_ruleset()
{
var person = new Employee()
{
Name = new EmployeeName()
{
First = string.Empty,
Last = string.Empty
}
};
var ruleSetValidator =
ValidationFactory.CreateValidator<Employee>("A");
var validationResults = ruleSetValidator.Validate(person);
Assert.That(!validationResults.IsValid,
"Validation with rulsets failed");
}
}
This test passes if I remove remove the Ruleset stuff. But once the ruleset is applied, I cant get the object to validate correctly.
Can anyone shed some light on this?
Cheers,