public void do_not_log_any_messages_when_the_collection_is_valid()
        {
            var target = new CollectionLengthTarget(){
                Names = new[]{"a"}
            };

            var rule = new CollectionLengthRule(1);
            rule.ValidateProperty(target, x => x.Names).MessagesFor<CollectionLengthTarget>(x => x.Names).Any().ShouldBeFalse();
        }
        public void log_message_when_collection_is_wrong_length()
        {
            var target = new CollectionLengthTarget(){
                Names = new string[0]
            };

            var rule = new CollectionLengthRule(1);
            rule.ValidateProperty(target, x => x.Names).MessagesFor<CollectionLengthTarget>(x => x.Names).Single().GetMessage()
                .ShouldEqual("Must be exactly 1 element(s)"); 
        }
Esempio n. 3
0
        public void do_not_log_any_messages_when_the_collection_is_valid()
        {
            var target = new CollectionLengthTarget()
            {
                Names = new[] { "a" }
            };

            var rule = new CollectionLengthRule(1);

            rule.ValidateProperty(target, x => x.Names).MessagesFor <CollectionLengthTarget>(x => x.Names).Any().ShouldBeFalse();
        }
Esempio n. 4
0
        public void log_message_when_collection_is_wrong_length_w()
        {
            var target = new CollectionLengthTarget()
            {
                Names = new string[] { "a" }
            };

            var rule = new CollectionLengthRule(2);

            rule.ValidateProperty(target, x => x.Names).MessagesFor <CollectionLengthTarget>(x => x.Names).Single().GetMessage()
            .ShouldEqual("Must be exactly 2 element(s)");
        }
Esempio n. 5
0
        public void log_message_when_collection_is_null()
        {
            var target = new CollectionLengthTarget()
            {
                Names = null
            };

            var rule = new CollectionLengthRule(1);

            rule.ValidateProperty(target, x => x.Names).MessagesFor <CollectionLengthTarget>(x => x.Names).Single().GetMessage()
            .ShouldEqual("Must be exactly 1 element(s)");
        }