public void GenericListNoValuesDefinedToBeAllowedPropertyNameEmpty() { ListPropertyDemoObject obj = new ListPropertyDemoObject(); obj.GenericListNoValuesAllowedPropertyNameEmpty.Add("ptv"); ValidationContext ctx = new ValidationContext(obj); ctx.MemberName = "GenericListNoValuesAllowedPropertyNameEmpty"; Action act = () => Validator.ValidateProperty(obj.GenericListNoValuesAllowedPropertyNameEmpty, ctx); act.ShouldThrowExactly <ValidationException>().WithMessage("'ptv' is not allowed value of 'GenericListNoValuesAllowedPropertyNameEmpty'! Please use one of these: *"); }
public void ListContainsNotAllowedStringValues() { ListPropertyDemoObject obj = new ListPropertyDemoObject(); obj.MyStringValues.Add("jee"); obj.MyStringValues.Add("ptv"); obj.MyStringValues.Add("quu"); ValidationContext ctx = new ValidationContext(obj); ctx.MemberName = "MyStringValues"; Action act = () => Validator.ValidateProperty(obj.MyStringValues, ctx); act.ShouldThrowExactly <ValidationException>().WithMessage("'jee' is not allowed value of 'MyStringValues'! Please use one of these: 'ptv, vrk, some other text'.*"); }