Beispiel #1
0
        public void Not_LengthBetween5And10()
        {
            var lengthBetween5And10         = new ExpressionSpecification <string>(s => s.Length >= 5 && s.Length <= 10);
            ISpecification <string> subject = lengthBetween5And10.Not();

            Assert.That(subject, Must.Not.Be.SatisfiedBy("123456"));
            Assert.That(subject, Must.Be.SatisfiedBy("1234").And("1234567890123"));
        }
Beispiel #2
0
 public void Test_Or_Specification()
 {
     var spec1 = new ExpressionSpecification <int>((x) =>
     {
         return(x > 10);
     }
                                                   , new string[] { "less than 10" });
     var spec2 = new ExpressionSpecification <int>((x) =>
     {
         return(x > 15);
     }
                                                   , new string[] { "less than 15" });
     var result = spec1.Not().ValidateWithMessages(12);
 }
Beispiel #3
0
        public void Test_And_Specification()
        {
            var spec1 = new ExpressionSpecification <int>((x) =>
            {
                return(x > 10);
            }
                                                          , new string[] { "less than 10" });
            var spec2 = new ExpressionSpecification <int>((x) =>
            {
                return(x > 15);
            }
                                                          , new string[] { "less than 15" });

            var spec3 = new ExpressionSpecification <int>((x) =>
            {
                return(x < 100 ? new[] { "less than 100" } : null);
            });

            var result = spec1.Not().ValidateWithMessagesAndContinue(22);
        }