Hi Jeremy / anyone else
FULL Gist REPO HERE
I'm trying to test A poco that reuses another POCO (like how your example's re-use an Address object / AddressValidator).
When I try and test this Validator using the test Extension Method(s), I'm -expecting- an error, but I do not get one :(
If I just call
on the Validator directly, I do
get the error messages (which prooves that the Validation has been setup correctly).
Could anyone please help me out?
Here's some snippets
from the gist
public void GivenANegativeValue_Validate_ShouldHaveAValidationError()
var landDetails = new LandDetails
Area = new UnitOfMeasure
Value = -111
var validator = new LandValidator();
validator.ShouldHaveChildValidator(land => land.Area, typeof(UnitOfMeasureValidator));
// This line of code SHOULD pass, but it doesn't because the validation doesn't error.
validator.ShouldHaveValidationErrorFor(land => land.Area, landDetails.Area);
// This works....
var results = validator.Validate(landDetails);
Ok - so I'm testing to make sure i've setup the validator. K, fine .. that works.
Next i'm testing a -property- .. which is
property. I'm also passing in a
decimal number so the validator should complain and say that's an error.
The code error there .. but it should pass - notice how I've said: Should-HAVE-AnError...
Anyways .. if you comment out that line and run the entire test, it will pass!