Exemplo n.º 1
0
        public void Generate_builds_valid_PESEL()
        {
            var peselGenerator = new PeselGenerator();

            for (int i = 0; i < 100; i++)
            {
                string pesel = peselGenerator.Generate();

                Assert.IsTrue(
                    PeselValidator.IsValid(pesel),
                    string.Format("Failed nr: [{0}], pesel: [{1}]", i, pesel));
            }
        }
Exemplo n.º 2
0
        private string RandomPESEL(HashSet <string> Pesele)
        {
            var    a = new PeselGenerator();
            string Pesel;

            do
            {
                Pesel = a.Generate(1900);
                if ((Int64.Parse(Pesel) / 10) % 2 == 0)
                {
                    mezczyzna = false;
                }
                else
                {
                    mezczyzna = true;
                }
            } while (Pesele.Contains(Pesel));


            return(Pesel);
        }
Exemplo n.º 3
0
        private void InitializeHotKeys()
        {
            _hotKeyManager  = new HotKeyManager();
            _nipGenerator   = new NipGenerator();
            _peselGenerator = new PeselGenerator();

            _hotKeyManager.RegisterHotKey(
                KeyModifier.NotSet,
                Keys.F7,
                () =>
            {
                string newNip = _nipGenerator.Generate();
                SendKeys.SendWait(newNip);
                AddNipNumberToHistory(newNip);
            });

            _hotKeyManager.RegisterHotKey(
                KeyModifier.NotSet,
                Keys.F8,
                () =>
            {
                string newPesel = _peselGenerator.Generate();
                SendKeys.SendWait(newPesel);
                AddPeselNumberToHistory(newPesel);
            });

            _hotKeyManager.RegisterHotKey(
                KeyModifier.NotSet,
                Keys.F9,
                () =>
            {
                if (!this.IsActive)
                {
                    this.Visibility = Visibility.Visible;
                    this.Activate();
                }
            });
        }
Exemplo n.º 4
0
        public void GetPeselMonthShiftedByYear_gets_month_for_PESEL_according_to_year()
        {
            var testCaseData = new[] {
                new { Date = new DateTime(1900, 1, 1), ExpectedMonth = "01" },
                new { Date = new DateTime(1999, 1, 1), ExpectedMonth = "01" },
                new { Date = new DateTime(2000, 1, 1), ExpectedMonth = "21" },
                new { Date = new DateTime(2099, 1, 1), ExpectedMonth = "21" },
                new { Date = new DateTime(2100, 1, 1), ExpectedMonth = "41" },
                new { Date = new DateTime(2199, 1, 1), ExpectedMonth = "41" },
                new { Date = new DateTime(2200, 1, 1), ExpectedMonth = "61" },
                new { Date = new DateTime(2299, 1, 1), ExpectedMonth = "61" },
            };

            foreach (var testCase in testCaseData)
            {
                string month = PeselGenerator.GetPeselMonthShiftedByYear(testCase.Date);

                Assert.AreEqual(
                    testCase.ExpectedMonth,
                    month,
                    string.Format("Failed for date: [{0}], expected month: [{1}] but was [{2}]", testCase.Date, testCase.ExpectedMonth, month));
            }
        }
Exemplo n.º 5
0
 public void GetPeselMonthShiftedByYear_is_supported_to_year_2299()
 {
     PeselGenerator.GetPeselMonthShiftedByYear(new DateTime(2300, 1, 1));
 }
Exemplo n.º 6
0
 public void GetPeselMonthShiftedByYear_is_supported_from_year_1900()
 {
     PeselGenerator.GetPeselMonthShiftedByYear(new DateTime(1899, 1, 1));
 }