public void register_simple_rules_by_filter()
        {
            theSource = new LambdaFieldValidationSource(new RequiredFieldRule());
            theSource.If(a => a.Name.StartsWith("Address"));

            rulesFor(x => x.Name).Any().ShouldBeFalse();
            rulesFor(x => x.Address1).Single().ShouldBeOfType<RequiredFieldRule>();
            rulesFor(x => x.Address2).Single().ShouldBeOfType<RequiredFieldRule>();
        }
Exemplo n.º 2
0
        public void register_simple_rules_by_filter()
        {
            theSource = new LambdaFieldValidationSource(new RequiredFieldRule());
            theSource.If(a => a.Name.StartsWith("Address"));

            rulesFor(x => x.Name).Any().ShouldBeFalse();
            rulesFor(x => x.Address1).Single().ShouldBeOfType <RequiredFieldRule>();
            rulesFor(x => x.Address2).Single().ShouldBeOfType <RequiredFieldRule>();
        }
        public void register_simple_rules_by_rule_func()
        {
            theSource = new LambdaFieldValidationSource(a =>
            {
                var length = int.Parse(a.Name.Substring(7, 1));
                return new MaximumLengthRule(length);
            });

            theSource.If(a => a.Name.StartsWith("Address"));

            rulesFor(x => x.Name).Any().ShouldBeFalse();
            rulesFor(x => x.Address1).Single().ShouldBeOfType<MaximumLengthRule>().Length.ShouldEqual(1);
            rulesFor(x => x.Address2).Single().ShouldBeOfType<MaximumLengthRule>().Length.ShouldEqual(2);
        }
Exemplo n.º 4
0
        public void register_simple_rules_by_rule_func()
        {
            theSource = new LambdaFieldValidationSource(a =>
            {
                var length = int.Parse(a.Name.Substring(7, 1));
                return(new MaximumLengthRule(length));
            });

            theSource.If(a => a.Name.StartsWith("Address"));

            rulesFor(x => x.Name).Any().ShouldBeFalse();
            rulesFor(x => x.Address1).Single().ShouldBeOfType <MaximumLengthRule>().Length.ShouldEqual(1);
            rulesFor(x => x.Address2).Single().ShouldBeOfType <MaximumLengthRule>().Length.ShouldEqual(2);
        }