コード例 #1
0
        public void Should_AddRule_MultipleRules()
        {
            var memberValidator = new MemberValidator();

            var rule1 = new ValidRule<int>(c => true);
            var rule2 = new AsRelativeRule<object>(c => true);
            var rule3 = new AsModelRule<object>();

            memberValidator.AddRule(rule1);
            memberValidator.AddRule(rule2);
            memberValidator.AddRule(rule3);

            Assert.Equal(3, memberValidator.Rules.Count);
            Assert.Same(rule1, memberValidator.Rules.ElementAt(0));
            Assert.Same(rule2, memberValidator.Rules.ElementAt(1));
            Assert.Same(rule3, memberValidator.Rules.ElementAt(2));
        }
コード例 #2
0
        public void Should_AddRule_SingleRule()
        {
            var memberValidator = new MemberValidator();

            var rule = new ValidRule<int>(c => true);
            memberValidator.AddRule(rule);

            Assert.Single(memberValidator.Rules);
            Assert.Same(rule, memberValidator.Rules.Single());
        }
コード例 #3
0
        public void Should_AddRule_ThrowException_When_NullRule()
        {
            var memberValidator = new MemberValidator();

            Assert.Throws<ArgumentNullException>(() => { memberValidator.AddRule(null); });
        }