Exemple #1
0
        public void AlphaValidationLengthRangeException()
        {
            var message = "Input is invalid.";

            try
            {
                var success = AntiXssValidation.IsAlphabetic("!aa", 2, 4, false, false);
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual(message, e.Message);
            }

            try
            {
                var success = AntiXssValidation.IsAlphabetic(null, 2, 4, false, false);
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual(message, e.Message);
            }
            Assert.IsTrue(AntiXssValidation.IsAlphabetic("aaa", 2, 4, false, false));
            Assert.IsTrue(AntiXssValidation.IsAlphabetic(null, 2, 4, true, false));
            Assert.IsFalse(AntiXssValidation.IsAlphabetic("!a", 2, 4, false, true));
            Assert.IsFalse(AntiXssValidation.IsAlphabetic(null, 2, 4, false, true));
        }
Exemple #2
0
 public void AlphaValidationWithNullInput()
 {
     Assert.IsTrue(AntiXssValidation.IsAlphabetic(null, 1, true));
     Assert.IsTrue(AntiXssValidation.IsAlphabetic(null, 1, 2, true));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic(null, 1, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic(null, 1, 2, false));
 }
Exemple #3
0
 public void AlphaValidationSpecificLength()
 {
     Assert.IsTrue(AntiXssValidation.IsAlphabetic("aaa", 3, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("aa", 3, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("", 3, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic(" ", 3, false));
 }
Exemple #4
0
 public void AlphaValidationLengthRange()
 {
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("a", 2, 3, false));
     Assert.IsTrue(AntiXssValidation.IsAlphabetic("aa", 2, 3, false));
     Assert.IsTrue(AntiXssValidation.IsAlphabetic("aaa", 2, 3, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("aaaa", 2, 3, false));
 }
Exemple #5
0
 public void AlphaValidationAnyLength()
 {
     Assert.IsTrue(AntiXssValidation.IsAlphabetic("aaAAjj", 0, false));
     Assert.IsTrue(AntiXssValidation.IsAlphabetic("aaAAjjrr", 0, false));
     Assert.IsTrue(AntiXssValidation.IsAlphabetic("this string".Replace(" ", ""), 0, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("this string", 0, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("aa1AAjjrr", 0, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic("", 0, false));
     Assert.IsFalse(AntiXssValidation.IsAlphabetic(" ", 0, false));
 }