Hello ,
I have a MyBO class which contains:
...
[RangeValidator(typeof(byte), "0", RangeBoundaryType.Inclusive, "20", RangeBoundaryType.Inclusive, Ruleset="validate_x")]
public byte x
{
get;
set;
}
[IgnoreNulls]
[RangeValidator(typeof(byte), "0", RangeBoundaryType.Inclusive, "50", RangeBoundaryType.Inclusive, Ruleset = "validate_y")]
public byte y
{
get;
set;
}
[SelfValidation(Ruleset="validate_xy")]
public void VerifyXY(ValidationResults results)
{
if (x < y)
{
results.AddResult(new ValidationResult("X cannot be < than Y!", this, "Verify", null, null));
}
}
The problem is that if in a test class i have:
[TestMethod()]
public void MyBOConstructorTest()
{
MyBO target = new MyBO() { x = 20, y = 23 };
ValidationResults vr = Validation.Validate(target, "validate_xy");
Assert.IsTrue(vr.IsValid);
}
the test does not fail. Why? Because X is 20 and Y 23. So as you can see i'm using SelfValidation in the BO class.
Thanls