public void Generate_AllCharacters_VerifyLength()
        {
            var subject = new SimplePasswordGenerator();

            string actual = subject.Generate(10, Charsets.All);

            Assert.That(actual, Has.Length.EqualTo(10));
        }
        public void Generate_DigitsOnly_Verify()
        {
            var subject = new SimplePasswordGenerator();

            string actual = subject.Generate(10, Charsets.Digits);

            Assert.That(actual, Has.Length.EqualTo(10)
                        .With.All.Matches <char>(char.IsNumber),
                        "ten digits");
        }
        public void Generate_SpecialCharactersOnly_Verify()
        {
            var subject = new SimplePasswordGenerator();

            string actual = subject.Generate(10, Charsets.SpecialCharacters);

            Assert.That(actual, Has.Length.EqualTo(10)
                        .With.None.Matches <char>(char.IsLetterOrDigit),
                        "ten special characters");
        }
        public void Generate_AlphaNumericOnly_Verify()
        {
            var subject = new SimplePasswordGenerator();

            string actual = subject.Generate(10, Charsets.AlphaNumeric);

            Assert.That(actual, Has.Length.EqualTo(10)
                        .With.All.Matches <char>(char.IsLetterOrDigit),
                        "ten alphanumeric characters");
        }
        public static bool CreateUser(string Email, string culture)
        {
            // Validate input
            if (string.IsNullOrEmpty(Email))
            {
                throw new ArgumentException("Argument cannot be null or empty", "Email");
            }
            Email = Email.Trim();


            // Generate a password
            IPasswordGenerator passwordGenerator = new SimplePasswordGenerator();
            string             password          = passwordGenerator.Generate(7);

            // Encrypt information
            ICrypt crypt = new SimpleCrypt();

            Email    = crypt.Encrypt(Email);
            password = crypt.Encrypt(password);

            return(DomainModel.Repository.Sql.Users.Create(Email, password, culture));
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            var minLength = GetNumericValueFromConsole("What's the minimum length?");
            var numberSpecialCharacters = GetNumericValueFromConsole("How many special characters?");
            var howManyNumbers          = GetNumericValueFromConsole("How many numbers?");


            var passwordGenerationCriteria = new PasswordGenerationCriteria()
            {
                MinimumLength             = minLength,
                NumbersQuantity           = howManyNumbers,
                SpecialCharactersQuantity = numberSpecialCharacters
            };

            IPasswordGenerator generator = new SimplePasswordGenerator();
            var password = generator.GetPassword(passwordGenerationCriteria);

            Console.WriteLine("Your password is:");
            Console.WriteLine(password);

            Clipboard.SetText(password);
            Console.ReadLine();
        }