public void Should_be_able_to_add_aditional_required_properties_to_validation_rule() { DefaultPropertyConvention defaultPropertyConvention = new DefaultPropertyConvention(x => x.Name.Contains("question")); var properties = new AdditionalProperties(); var expression = new AdditionalPropertyExpression(properties); expression.NeedsAdditionalPropertyMatching(p => p.Name.Contains("answer")); expression.NeedsAdditionalPropertyMatching(p => !p.Name.Contains("question")); defaultPropertyConvention.AddValidationRule <IsRequired <CanBeAnyViewModel> >(properties); defaultPropertyConvention.GetValidationRules().Count().ShouldEqual(1); defaultPropertyConvention.GetAdditionalPropertiesForRule(defaultPropertyConvention.GetValidationRules().First()).Count().ShouldEqual(2); }
public void Should_be_able_to_add_validation_rules_to_default_property_convention() { DefaultPropertyConvention defaultPropertyConvention = new DefaultPropertyConvention(x => x.Name.Contains("")); defaultPropertyConvention.AddValidationRule <IsRequired <CanBeAnyViewModel> >(); defaultPropertyConvention.GetValidationRules().Count().ShouldEqual(1); }
public void Should_be_able_to_add_aditional_required_properties_to_validation_rule() { DefaultPropertyConvention defaultPropertyConvention = new DefaultPropertyConvention(x => x.Name.Contains("question")); var properties = new AdditionalProperties(); var expression = new AdditionalPropertyExpression(properties); expression.NeedsAdditionalPropertyMatching(p => p.Name.Contains("answer")); expression.NeedsAdditionalPropertyMatching(p => !p.Name.Contains("question")); defaultPropertyConvention.AddValidationRule<IsRequired<CanBeAnyViewModel>>(properties); defaultPropertyConvention.GetValidationRules().Count().ShouldEqual(1); defaultPropertyConvention.GetAdditionalPropertiesForRule(defaultPropertyConvention.GetValidationRules().First()).Count().ShouldEqual(2); }
public void Should_not_be_able_to_add_duplicate_validation_rules_to_default_property_convention() { DefaultPropertyConvention defaultPropertyConvention = new DefaultPropertyConvention(x => x.Name.Contains("")); defaultPropertyConvention.AddValidationRule<IsRequired<CanBeAnyViewModel>>(); defaultPropertyConvention.AddValidationRule<IsRequired<CanBeAnyViewModel>>(); defaultPropertyConvention.GetValidationRules().Count().ShouldEqual(1); }