Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public void Default()
        {
            RuleAssert.For <Guid>(Is.Default)
            .ExpectNone(Guid.Empty)
            .ExpectError(Guid.NewGuid());

            RuleAssert.For <int>(Is.Default)
            .ExpectNone(0)
            .ExpectError(1, 2);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
 public void ValidAnd()
 {
     RuleAssert.For(MaybeIs.ValidAnd(StringIs.WithoutUppercase))
     .ExpectNone("lowercase")
     .ExpectError(null, Maybe.String, "Uppercase");
 }
Пример #7
0
 public void Equal_X()
 {
     RuleAssert.For(Is.Equal(Tuple.From(1, 2)))
     .ExpectNone(Tuple.From(1, 2))
     .ExpectError(Tuple.From(2, 1), Tuple.From(3, 4));
 }
Пример #8
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));
 }
Пример #9
0
 public void ValidHost_Positives()
 {
     RuleAssert.For <string>(StringIs.ValidServerConnection)
     .ExpectNone(Split(ValidHostNames));
 }
Пример #10
0
 public void ValidEmail_Positives()
 {
     RuleAssert.For <string>(StringIs.ValidEmail)
     .ExpectNone(Split(ValidEmails));
 }
Пример #11
0
 public void WithoutTrailingWhiteSpace()
 {
     RuleAssert.For(StringIs.WithoutTrailingWhiteSpace)
     .ExpectNone("", "non", " leading", "mid dle")
     .ExpectError(null, "new line\r", "new line\n", "tab\t", "space ");
 }
Пример #12
0
 public void Without_X()
 {
     RuleAssert.For(StringIs.Without('!'))
     .ExpectNone("", "ABCD", "?@#")
     .ExpectError(null, "!", "ABCD!");
 }
Пример #13
0
 public void True_X()
 {
     RuleAssert.For(Is.True <int>(i => (i > 2) && (i % 2 == 0)))
     .ExpectNone(4, 6)
     .ExpectError(0, 1, 3, 5);
 }
Пример #14
0
 public void Value_X()
 {
     RuleAssert.For(Is.Value(RuleLevel.Error))
     .ExpectNone(RuleLevel.Error)
     .ExpectError(RuleLevel.None, RuleLevel.Warn);
 }
Пример #15
0
 public void ValidHost_Negatives()
 {
     RuleAssert.For <string>(StringIs.ValidServerConnection)
     .ExpectError(Split(InvalidHostNames));
 }
Пример #16
0
 public void Limited_X()
 {
     RuleAssert.For(StringIs.Limited(3))
     .ExpectNone("", "A", "AA", "AAA")
     .ExpectError(null, "AAAA");
 }
Пример #17
0
 public void GreaterThen_X()
 {
     RuleAssert.For(Is.GreaterThan(5D))
     .ExpectNone(6, 6D, 5.1D)
     .ExpectError(5, 5D, 2);
 }
Пример #18
0
 public void WithoutLeadingWhiteSpace()
 {
     RuleAssert.For(StringIs.WithoutLeadingWhiteSpace)
     .ExpectNone("", "non", "trailing ", "mid dle")
     .ExpectError(null, "\r new line", "\n new line", "\t tab", " space");
 }
Пример #19
0
 public void LessThan_X()
 {
     RuleAssert.For(Is.LessThan(5D))
     .ExpectNone(4.9, 4D, 3)
     .ExpectError(5, 5D, 6);
 }
Пример #20
0
 public void WithoutUppercase()
 {
     RuleAssert.For(StringIs.WithoutUppercase)
     .ExpectNone("", "valid", "another\tvalid")
     .ExpectError("Fail", "\tthis should Fail");
 }
Пример #21
0
 public void AtMost_X()
 {
     RuleAssert.For(Is.AtMost(5D))
     .ExpectNone(-1, 4D, 5D, 5)
     .ExpectError(5.000001, 6D);
 }
Пример #22
0
 public void ValidEmail_Negatives()
 {
     RuleAssert.For <string>(StringIs.ValidEmail)
     .ExpectError(Split(InvalidEmails));
 }
 public void Limited()
 {
     RuleAssert.For(BufferIs.Limited(10))
     .ExpectNone(new byte[10], new byte[9])
     .ExpectError(null, new byte[11], new byte[12]);
 }
 public void Expect()
 {
     RuleAssert.For <int>(Is.Default).ExpectNone(1);
 }
Пример #25
0
 public void EmptyOr()
 {
     RuleAssert.For(MaybeIs.EmptyOr(StringIs.WithoutUppercase))
     .ExpectNone(Maybe <string> .Empty, "lowercase")
     .ExpectError(null, "UpperCase");
 }
Пример #26
0
 public void Valid()
 {
     RuleAssert.For <double>(DoubleIs.Valid)
     .ExpectError(double.NaN, 1 / 0D, double.PositiveInfinity, double.NegativeInfinity)
     .ExpectNone(1D, 0D, Math.PI);
 }
Пример #27
0
 public void AtLeast_X()
 {
     RuleAssert.For(Is.AtLeast(5D))
     .ExpectNone(10, 6D, 5D, 5)
     .ExpectError(4.999999, 4D);
 }