Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public static MonthlySettings Random(string name, string clf, DateTime date, bool interval = false)
        {
            MonthlySettings result = new MonthlySettings();

            result.Wiring  = Wiring.Random(interval);
            Wiring.Current = result.Wiring;

            result.Name             = name;
            result.Classification   = clf;
            result.Date             = new DateTime(date.Year, date.Month, 1);
            result.Indicator        = RandomUtil.GetRandomAlpha(GROUP_SIZE);
            result.NumericIndicator = RandomUtil.GetRandomNumeric(GROUP_SIZE);

            for (int d = 1; d <= DateTime.DaysInMonth(date.Year, date.Month); d++)
            {
                result.DailySettings.Add(Settings.Random());

                result.DailySettings.Last().Date = new DateTime(date.Year, date.Month, d);
            }

            result.DailySettings.ForEach(s =>
            {
                s.ParentSettings = result;
                s.ParentId       = result.Id;
            });

            IndicatorUtil.FixDuplicateIndicators(result.DailySettings);

            return(result);
        }
Exemplo n.º 3
0
        public static YearlySettings Random(string title, string classification, DateTime date, bool interval = false)
        {
            YearlySettings result = new YearlySettings
            {
                Date             = date,
                Classification   = classification,
                Name             = title,
                Indicator        = RandomUtil.GetRandomAlpha(5),
                NumericIndicator = RandomUtil.GetRandomNumeric(5)
            };

            for (int i = 1; i <= 12; i++)
            {
                result.MonthlySettings.Add(KL7A.Configuration.MonthlySettings.Random(title, classification, new DateTime(date.Year, i, 1), interval));
            }

            result.MonthlySettings.ForEach(m =>
            {
                m.ParentId       = result.Id;
                m.ParentSettings = result;
            });

            IndicatorUtil.FixDuplicateIndicators(result.MonthlySettings);
            IndicatorUtil.FixDuplicateIndicators(result.MonthlySettings.SelectMany(m => m.DailySettings));

            return(result);
        }