public void register_multiple_rules_for_a_single_property()
        {
            theRules.Property(x => x.Name).Required().MaximumLength(10);

            var nameRules = rulesFor(x => x.Name);

            CoreExtensions.Count(nameRules).ShouldBe(2);
            nameRules.Any(x => x is RequiredFieldRule).ShouldBeTrue();
            nameRules.ShouldContain(new MaximumLengthRule(10));
        }
Example #2
0
        public void to_validation_error_simple()
        {
            var notification = new Notification();

            notification.RegisterMessage <EntityToValidate>(e => e.Something, StringToken.FromKeyString("test1", "test1"));
            notification.RegisterMessage <EntityToValidate>(e => e.Something, StringToken.FromKeyString("test2", "test2"));
            notification.RegisterMessage <EntityToValidate>(e => e.Something, StringToken.FromKeyString("test3", "test3"));

            var errors = notification.ToValidationErrors();

            CoreExtensions.Count(errors).ShouldBe(3);
            errors.First().message.ShouldBe("test1");
            errors.First().field.ShouldBe("Something");
        }