Validate the number of non alphanumeric characters to the value set in the web.confg/system.web/membership section.
Inheritance: PropertyRule
Exemple #1
0
        public void min_required_non_alpha_chars_returns_true_when_zero_required_non_alpha_chars_are_required()
        {
            // Arrange
            string password = "******";
            string username = "******";
            int numOfRequiredNonAlphaChars = 0;

            // Act
            var rule = new MinRequiredNonAlphanumericCharacters(username, password, numOfRequiredNonAlphaChars);
            bool actual = rule.Validate();

            // Assert
            Assert.IsTrue(actual);
        }
Exemple #2
0
        public void min_required_non_alpha_chars_returns_false_when_3_required_non_alpha_chars_are_required_and_2_are_found()
        {
            // Arrange
            string password = "******";
            string username = "******";
            int numOfRequiredNonAlphaChars = 3;

            // Act
            var rule = new MinRequiredNonAlphanumericCharacters(username, password, numOfRequiredNonAlphaChars);
            bool actual = rule.Validate();

            // Assert
            Assert.IsFalse(actual);
        }
Exemple #3
0
        public void min_required_non_alpha_chars_returns_proper_error_message()
        {
            // Arrange
            string password = "******";
            string username = "******";
            int numOfRequiredNonAlphaChars = 1;

            // Act
            var rule = new MinRequiredNonAlphanumericCharacters(username, password, numOfRequiredNonAlphaChars);
            string actual = rule.ErrorMessage;

            // Assert
            Assert.AreEqual("The password for 'myusername' does not contain the minimum number of required alphanumeric characters.", actual);
        }