Exemple #1
0
        void ExecuteGenerateCommand()
        {
            IsBusy = true;

            var unitSelections = ParameterSet.UnitSelections
                                 .Select(pus => new UnitSelection(pus.UnitSet, pus.Bounds))
                                 .ToList();

            if (ParameterSet.IsLegacy)
            {
                Password = PasswordGeneratorLegacy.Generate(
                    MasterPassword, Keyword, OptionalKeyword, Modifier,
                    ParameterSet.Length, unitSelections);
            }
            else
            {
                var generator = new PasswordGenerator()
                {
                    MasterPassword = MasterPassword,
                    Keyword        = Keyword + "\n" + OptionalKeyword,
                    Modifier       = Modifier,
                    Length         = ParameterSet.Length,
                    UnitSets       = unitSelections
                };
                Password = generator.Generate();
            }

            IsBusy = false;
        }
        public void LengthTest()
        {
            string master          = "d";
            string keyword         = "d";
            string optionalKeyword = null;
            string modifier        = null;
            int    length          = 11;
            var    unitSets        = new List <UnitSelection>()
            {
                new UnitSelection(PasswordUnitSet.Lowercase, Bounds.AtLeastOne),
                new UnitSelection(PasswordUnitSet.Uppercase, Bounds.AtLeastOne),
                new UnitSelection(PasswordUnitSet.Numbers, Bounds.AtLeastOne),
                new UnitSelection(PasswordUnitSet.CompleteSymbols, Bounds.AtLeastOne),
            };

            string result = PasswordGeneratorLegacy.Generate(
                master, keyword, optionalKeyword, modifier, length, unitSets);

            Assert.AreEqual(result, @"fSQ!JBSZS8|");
        }