public void UseCase_For_That()
        {
            var visitor = new Visitor
            {
                Programs = new[]
                {
                    new Program
                    {
                        Name = "Some"
                    },
                    new Program
                    {
                        Active = false
                    },
                }
            };

            //Assert.IsTrue(visitor.Programs.Exists(p => p.Active),
            //    "visitor should have at least one active program");

            RuleAssert.That(() => visitor,
                            v => v.Programs.Exists(p => p.Active),
                            v => v.Programs.Length > 1);

            RuleAssert.That(visitor,
                            v => v.Programs.Exists(p => p.Active),
                            v => v.Programs.Length > 1);
        }
 public void Invalid_property_collection()
 {
     RuleAssert.IsError(new Model()
     {
         Login = "******",
         Name  = "valid",
         Names = new [] { "" }
     }, ValidateModelExpression);
 }
 public void Invalid_field_collection()
 {
     RuleAssert.IsError(new Model()
     {
         Login  = "******",
         Name   = "valid",
         Logins = new[] { "non-email" }
     }, ValidateModelExpression);
 }
        public void NotEqual_X()
        {
            RuleAssert.For(Is.NotEqual(Guid.Empty))
            .ExpectNone(Guid.NewGuid())
            .ExpectError(Guid.Empty);

            RuleAssert.For(Is.NotEqual(3D))
            .ExpectNone(1, 2, Math.PI)
            .ExpectError(3, 3D);
        }
        public void NotDefault()
        {
            RuleAssert.For <Guid>(Is.NotDefault)
            .ExpectNone(Guid.NewGuid())
            .ExpectError(Guid.Empty);

            RuleAssert.For <double>(Is.NotDefault)
            .ExpectNone(1, 2)
            .ExpectError(0, 0D);
        }
        public void Default()
        {
            RuleAssert.For <Guid>(Is.Default)
            .ExpectNone(Guid.Empty)
            .ExpectError(Guid.NewGuid());

            RuleAssert.For <int>(Is.Default)
            .ExpectNone(0)
            .ExpectError(1, 2);
        }
        public void Within_X_Y()
        {
            RuleAssert.For(Is.Within(0, 20))
            .ExpectNone(0, 12, 20)
            .ExpectError(-1, 21, int.MaxValue);

            RuleAssert.For(Is.Within(0D, 20D))
            .ExpectNone(0, 12, 20)
            .ExpectError(-1, 21, int.MaxValue);
        }
        public void Invalid_field()
        {
            var model = new Model()
            {
                Login = "******",
                Name  = ""
            };

            RuleAssert.IsError(model, ValidateModelExpression);
        }
        public void Invalid_property()
        {
            var model = new Model()
            {
                Login = "******",
                Name  = "valid"
            };

            RuleAssert.IsError(model, ValidateModelExpression);
        }
 public void Valid_model()
 {
     RuleAssert.IsNone(new Model()
     {
         Login  = "******",
         Name   = "valid",
         Logins = new[] { "*****@*****.**" },
         Names  = new [] { "Another name" }
     }, ValidateModelExpression);
 }
        public void Between_X_Y()
        {
            RuleAssert.For(Is.Between(0, 20))
            .ExpectNone(1, 15, 19)
            .ExpectError(-1, 0, 20, int.MaxValue);

            RuleAssert.For(Is.Between(0D, 20D))
            .ExpectNone(1, 15, 19)
            .ExpectError(-1, 0, 20, int.MaxValue);
        }
Exemple #12
0
 public void WithoutUppercase()
 {
     RuleAssert.For(StringIs.WithoutUppercase)
     .ExpectNone("", "valid", "another\tvalid")
     .ExpectError("Fail", "\tthis should Fail");
 }
Exemple #13
0
 public void WithoutTrailingWhiteSpace()
 {
     RuleAssert.For(StringIs.WithoutTrailingWhiteSpace)
     .ExpectNone("", "non", " leading", "mid dle")
     .ExpectError(null, "new line\r", "new line\n", "tab\t", "space ");
 }
Exemple #14
0
 public void WithoutLeadingWhiteSpace()
 {
     RuleAssert.For(StringIs.WithoutLeadingWhiteSpace)
     .ExpectNone("", "non", "trailing ", "mid dle")
     .ExpectError(null, "\r new line", "\n new line", "\t tab", " space");
 }
 public void Limited()
 {
     RuleAssert.For(BufferIs.Limited(10))
     .ExpectNone(new byte[10], new byte[9])
     .ExpectError(null, new byte[11], new byte[12]);
 }
Exemple #16
0
 public void Test()
 {
     RuleAssert.For <DateTime>(DateIs.SqlCompatible)
     .ExpectNone(new DateTime(1753, 1, 1), DateTime.MaxValue)
     .ExpectError(DateTime.MinValue, new DateTime(1753, 1, 1).AddSeconds(-1));
 }
 public void GreaterThen_X()
 {
     RuleAssert.For(Is.GreaterThan(5D))
     .ExpectNone(6, 6D, 5.1D)
     .ExpectError(5, 5D, 2);
 }
Exemple #18
0
 public void ValidHost_Positives()
 {
     RuleAssert.For <string>(StringIs.ValidServerConnection)
     .ExpectNone(Split(ValidHostNames));
 }
 public void LessThan_X()
 {
     RuleAssert.For(Is.LessThan(5D))
     .ExpectNone(4.9, 4D, 3)
     .ExpectError(5, 5D, 6);
 }
Exemple #20
0
 public void ValidAnd()
 {
     RuleAssert.For(MaybeIs.ValidAnd(StringIs.WithoutUppercase))
     .ExpectNone("lowercase")
     .ExpectError(null, Maybe.String, "Uppercase");
 }
Exemple #21
0
 public void EmptyOr()
 {
     RuleAssert.For(MaybeIs.EmptyOr(StringIs.WithoutUppercase))
     .ExpectNone(Maybe <string> .Empty, "lowercase")
     .ExpectError(null, "UpperCase");
 }
Exemple #22
0
 public void ValidEmail_Positives()
 {
     RuleAssert.For <string>(StringIs.ValidEmail)
     .ExpectNone(Split(ValidEmails));
 }
Exemple #23
0
 public void ValidEmail_Negatives()
 {
     RuleAssert.For <string>(StringIs.ValidEmail)
     .ExpectError(Split(InvalidEmails));
 }
Exemple #24
0
 public void ValidHost_Negatives()
 {
     RuleAssert.For <string>(StringIs.ValidServerConnection)
     .ExpectError(Split(InvalidHostNames));
 }
 public void UseCases()
 {
     RuleAssert.IsNone(1, Is.NotDefault);
     RuleAssert.IsError(1, Is.Default);
     RuleAssert.IsWarn(1, (i, scope) => scope.Warn("Warning"));
 }
Exemple #26
0
 public void Limited_X()
 {
     RuleAssert.For(StringIs.Limited(3))
     .ExpectNone("", "A", "AA", "AAA")
     .ExpectError(null, "AAAA");
 }
 public void Expect()
 {
     RuleAssert.For <int>(Is.Default).ExpectNone(1);
 }
Exemple #28
0
 public void Without_X()
 {
     RuleAssert.For(StringIs.Without('!'))
     .ExpectNone("", "ABCD", "?@#")
     .ExpectError(null, "!", "ABCD!");
 }
Exemple #29
0
 public void Valid()
 {
     RuleAssert.For <double>(DoubleIs.Valid)
     .ExpectError(double.NaN, 1 / 0D, double.PositiveInfinity, double.NegativeInfinity)
     .ExpectNone(1D, 0D, Math.PI);
 }
 public void AtMost_X()
 {
     RuleAssert.For(Is.AtMost(5D))
     .ExpectNone(-1, 4D, 5D, 5)
     .ExpectError(5.000001, 6D);
 }