Hi,
We have tree class structure, and some properties from leafs are validated only when property from root are checked. Cause it's hard to make conditional validator for whole class, we decided to write validations rules from root. Then i wanted to test, but such code is not working:
Now we have to write tests like that:
We have tree class structure, and some properties from leafs are validated only when property from root are checked. Cause it's hard to make conditional validator for whole class, we decided to write validations rules from root. Then i wanted to test, but such code is not working:
_validator.ShouldHaveValidationErrorFor(el => el.Child.Child.Property, model);
,cause in ValidatorTester it checks only this.accessor.Member.Name. Shouldn't it get path like that: http://stackoverflow.com/a/3049904/1202306 ? Now we have to write tests like that:
var result = _validator.Validate(dto);
var error = result.Errors.FirstOrDefault(el => el.PropertyName == "Child.Child.Property");
Assert.IsNotNull(error);