Пример #1
0
        public void IsNumberRangeTest()
        {
            RegenPattern.IsNumberRange("123456", 4, 6).IsTrue();
            RegenPattern.IsNumberRange("1234", 4, 6).IsTrue();

            RegenPattern.IsNumberRange("123", 4, 6).IsFalse();

            RegenPattern.IsNumberRange("1234564", 4, 6).IsFalse();
            RegenPattern.IsNumberRange("1231p", 4, 6).IsFalse();
        }
Пример #2
0
        public void IsMatchTest()
        {
            string input = "23562564652";


            bool expected = true;
            bool actual;

            actual = RegenPattern.IsMatch(input, "^[0-9]*$");
            Assert.AreEqual(expected, actual);

            RegenPattern.IsMatch("蔡锐财", RegenPattern.ChinaName).AreEqualWith(true);
            RegenPattern.IsMatch("ckdk", RegenPattern.ChinaName).AreEqualWith(false);
            RegenPattern.IsMatch("123陈", RegenPattern.ChinaName).AreEqualWith(false);


            RegenPattern.IsMatch("*****@*****.**", RegenPattern.Email).AreEqualWith(true);
            RegenPattern.IsMatch("*****@*****.**", RegenPattern.Email).AreEqualWith(false);


            RegenPattern.IsMatch("445202198803252758", RegenPattern.IdentityCard).AreEqualWith(true);

            RegenPattern.IsMatch("192.168.0.1", RegenPattern.IPAddress).AreEqualWith(true);

            RegenPattern.IsMatch("0663-8887586", RegenPattern.PhoneNumber).AreEqualWith(true);

            RegenPattern.IsMatch("0663-8887586", RegenPattern.UserName).AreEqualWith(false);


            RegenPattern.IsMatch("39", RegenPattern.Age).AreEqualWith(true);
            RegenPattern.IsMatch("0", RegenPattern.Age).AreEqualWith(false);
            RegenPattern.IsMatch("129", RegenPattern.Age).AreEqualWith(true);
            RegenPattern.IsMatch("1", RegenPattern.Age).AreEqualWith(true);
            RegenPattern.IsMatch("130", RegenPattern.Age).AreEqualWith(false);
            RegenPattern.IsMatch("1291", RegenPattern.Age).AreEqualWith(false);

            RegenPattern.IsMatch("1291", RegenPattern.NaturalNumber).AreEqualWith(true);
            RegenPattern.IsMatch("1", RegenPattern.NaturalNumber).AreEqualWith(true);
            RegenPattern.IsMatch("0", RegenPattern.NaturalNumber).AreEqualWith(true);
            RegenPattern.IsMatch("0291", RegenPattern.NaturalNumber).AreEqualWith(false);
            RegenPattern.IsMatch("-191", RegenPattern.NaturalNumber).AreEqualWith(false);
            RegenPattern.IsMatch("0291", RegenPattern.NaturalNumber).AreEqualWith(false);
        }
Пример #3
0
 public void IsNumberMoreTest()
 {
     RegenPattern.IsNumberMore("12345", 5).IsTrue();
     RegenPattern.IsNumberMore("123454444", 5).IsTrue();
 }
Пример #4
0
 public void IsNumberTest()
 {
     RegenPattern.IsNumber("12345", 5).IsTrue();
     RegenPattern.IsNumber("12345", 4).IsFalse();
     RegenPattern.IsNumber("123466", 4).IsFalse();
 }