So, in a MyBO class i have:
[NotNullValidator(MessageTemplate = "Cannot be null!")]
[RangeValidator(0, RangeBoundaryType.Inclusive, 20, RangeBoundaryType.Inclusive, Ruleset="validate_x1")]
public byte x1
{
get;
set;
}
And in a test class:
[TestMethod()]
public void x1Test()
{
MyBO target = new MyBO() { x1 = (byte)20 };
ValidationResults vr = Validation.Validate(target, "validate_x1");
Assert.IsTrue(vr.IsValid);
}
Why i got: Test method TestProject.CatedraBOTest.x1Test threw exception: System.ArgumentException: Object must be of type Int32.. ?
I really don’t understand.
If i remove the RangeValidator everything works fine.
Please help.
Adding to what @Jason said, look at this where none of the constructor accept byte as parameter for range validation.
Having said that, you could use this if you still want to compare it with byte. In that case, it could look like
Note that the above line is written based on what I could see & interpret of the documentation. I have not written code to test if this works.
This is just to give you an idea of how things might work.
EDIT: The alternative could be to change the type of the property from byte to int.