Beispiel #1
0
        public static Settings Random()
        {
            Settings result = new Settings();

            result.Date             = DateTime.Now.Date;
            result.Indicator        = RandomUtil.GetRandomAlpha(5);
            result.NumericIndicator = RandomUtil.GetRandomNumeric(5);
            result.StartPosition    = RandomUtil.GetRandomAlpha(8);

            List <RotorName>     rotors  = RandomUtil.GetRandomEnumSequence <RotorName>(8);
            List <NotchRingName> notches = RandomUtil.GetRandomEnumSequence <NotchRingName>(8);

            for (int i = 0; i < 8; i++)
            {
                result.Rotors.Add(new RotorSetting
                {
                    RotorName            = rotors[i],
                    NotchRingName        = notches[i],
                    AlphabetRingPosition = RandomUtil._rand.Next(36),
                    NotchRingPosition    = RandomUtil._rand.Next(36),
                    ParentId             = result.Id,
                    ParentSettings       = result
                });
            }

            Machine m = new Machine(result);

            result.Check = m.Encipher(new string('L', 45)).Substring(35, 10);

            return(result);
        }