示例#1
0
        public void TestPasswordContainingUsernameIsInvalid()
        {
            // Arrange
            String username = "******";
            String password = "******";
            SimplePasswordChecker passwordChecker = new SimplePasswordChecker();

            // Act
            PasswordResult results = passwordChecker.ValidatePassword(username, password);

            // Assert
            Assert.Equal(false, results.ValidPassword);
            Assert.NotEmpty(results.Messages);
            Assert.Contains <String>("Your username of mmouse may not be used as part of the password", results.Messages);
        }
示例#2
0
        public void TestPasswordWithNoNumbersIsInvalid()
        {
            // Arrange
            String username = "******";
            String password = "******";
            SimplePasswordChecker passwordChecker = new SimplePasswordChecker();

            // Act
            PasswordResult results = passwordChecker.ValidatePassword(username, password);

            // Assert
            Assert.Equal(false, results.ValidPassword);
            Assert.NotEmpty(results.Messages);
            Assert.Contains <String>("The password must contain at least one number", results.Messages);
        }
示例#3
0
        public void TestEmptyStringPasswordIsInvalid()
        {
            // Arrange
            String username = "******";
            String password = String.Empty;
            SimplePasswordChecker passwordChecker = new SimplePasswordChecker();

            // Act
            PasswordResult results = passwordChecker.ValidatePassword(username, password);

            // Assert
            Assert.Equal(false, results.ValidPassword);
            Assert.NotEmpty(results.Messages);
            Assert.Contains <String>("A password value must be provided", results.Messages);
        }
示例#4
0
        public void TestPasswordShorterThanEightCharacters()
        {
            // Arrange
            String username = "******";
            String password = "******";
            SimplePasswordChecker passwordChecker = new SimplePasswordChecker();

            // Act
            PasswordResult results = passwordChecker.ValidatePassword(username, password);

            // Assert
            Assert.Equal(false, results.ValidPassword);
            Assert.NotEmpty(results.Messages);
            Assert.Contains <String>("The password must be 8 characters in length or greater", results.Messages);
        }
示例#5
0
        public void TestPreviouslyUsedPasswordIsInvalid()
        {
            // Arrange
            String username = "******";
            String password = "******";
            SimplePasswordChecker passwordChecker = new SimplePasswordChecker();

            // Act
            PasswordResult results = passwordChecker.ValidatePassword(username, password);

            // Assert
            Assert.Equal(false, results.ValidPassword);
            Assert.NotEmpty(results.Messages);
            Assert.Contains <String>("You have entered a password that you have used before.  Please enter a new password", results.Messages);
        }