コード例 #1
0
ファイル: Program.cs プロジェクト: pmcvtm/birthdayclub
        static void Main(string[] args)
        {
            PeopleRepository allPeople = null;
            PeopleRepository offLimitsPeople = null;
            ResultsRepository results = null;

            new OptionSet {
                { "allpeople=", s => {
                        allPeople = new PeopleRepository(File.ReadLines(s), s);
                    }
                }, { "offlimits=", s => {
                        offLimitsPeople = new PeopleRepository(File.ReadLines(s), s);
                    }
                }, { "results=", s => {
                        results = new ResultsRepository(s);
                    }
                }
            }.Parse(args);

            var nextBirthday = results.NextBirthday();
            var checkDate = new DateTime(DateTime.Now.Year, nextBirthday.Month, nextBirthday.Day).AddDays(1).AddSeconds(-1); // meh

            using (SystemClock.Stub(checkDate))
            {
                var personSource = new PersonSource(allPeople.GetPeople());
                var offLimitSource = new OffLimitsSource(offLimitsPeople.GetPeople(),
                    personSource.GetAllPeople().Length);

                var matcher = new Matcher(personSource, offLimitSource);

                results.Save(matcher.Next());
                offLimitsPeople.Save(matcher.GetOffLimits());
            }
        }
コード例 #2
0
        public void should_run()
        {
            var matcher = new Matcher(SampleData.People, new Person[0]);

            for (int i = 0; i < 250; i++)
            {
                Console.WriteLine(matcher.Next());
            }
        }
コード例 #3
0
ファイル: MatcherTests.cs プロジェクト: pmcvtm/birthdayclub
        public void should_run()
        {
            var personSource = new PersonSource(SampleData.People);
            var matcher = new Matcher(personSource, new OffLimitsSource(new Person[0], SampleData.People.Length));

            for (int i = 0; i < 250; i++)
            {
                using (SystemClock.Stub(DateTime.Now.AddMonths(i)))
                {
                    Console.WriteLine(matcher.Next());
                }
            }
        }