public void Wehn_upn_is_not_in_correct_format_should_throw_format_exception()
        {
            var samAccountNameGenerator = new SamAccountNameGenerator(_powerShellManager, _powershellScriptLoader);

            Assert.Throws <FormatException>(() =>
                                            samAccountNameGenerator.GenerateSamAccountName("random_non_email_format_string"));
        }
        public void When_upn_is_in_correct_format_should_return_string_less_than_20_characters(string upn)
        {
            _powershellScriptLoader.Stub(x => x.LoadScript(PowershellScripts.SamAccountNameAvailable)).Return(PowershellScripts.SamAccountNameAvailable);
            _powerShellManager.Stub(x => x.AddParameter(Arg <string> .Is.Anything, Arg <object> .Is.Anything));
            _powerShellManager.Stub(x => x.ExecuteScriptAndReturnFirst <bool>(PowershellScripts.SamAccountNameAvailable)).Return(true);

            var samAccountNameGenerator = new SamAccountNameGenerator(_powerShellManager, _powershellScriptLoader);

            var samAccountName = samAccountNameGenerator.GenerateSamAccountName(upn);

            samAccountName.Length.Should().BeLessThan(20, "SammAccaountName cannot be more than 20 characters");
        }
        public void When_upn_is_in_correct_format_should_return_only_alpha_numeric(string upn)
        {
            _powershellScriptLoader.Stub(x => x.LoadScript(PowershellScripts.SamAccountNameAvailable)).Return(PowershellScripts.SamAccountNameAvailable);
            _powerShellManager.Stub(x => x.AddParameter(Arg <string> .Is.Anything, Arg <object> .Is.Anything));
            _powerShellManager.Stub(x => x.ExecuteScriptAndReturnFirst <bool>(PowershellScripts.SamAccountNameAvailable)).Return(true);

            var samAccountNameGenerator = new SamAccountNameGenerator(_powerShellManager, _powershellScriptLoader);

            var samAccountName = samAccountNameGenerator.GenerateSamAccountName(upn);

            var alphaNumeric = new Regex("[^a-zA-Z0-9 -]");

            alphaNumeric.IsMatch(samAccountName).Should().Be(true);
        }
        public void Wehn_upn_is_null_or_empty_should_throw_argument_null_exception()
        {
            var samAccountNameGenerator = new SamAccountNameGenerator(_powerShellManager, _powershellScriptLoader);

            Assert.Throws <ArgumentNullException>(() => samAccountNameGenerator.GenerateSamAccountName(""));
        }