public void Occurrences_before_start()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule { Frequency = 7 };
            IList<DateTime> occurrences = Convert(year.GetOccurrences(_start, new DateTime(1900, 1, 1), new DateTime(1950, 1, 1)));

            Assert.AreEqual(0, occurrences.Count);
        }
        public void Occurrences_stress_test()
        {
            var d = new DateTime(900, 1, 1);
            YearlySchedule year = new YearlySchedule { Frequency = 1 };

            // 1/1/1900 (Monday) -> 31/12/1999 (Friday) = 36524 total days; 7 days in every 21 for 100 years; 36524 - 14 days = 36510 / 3 = 12170
            IList<DateTime> occurrences = Convert(year.GetOccurrences(d, d, new DateTime(2899, 12, 31)));

            Assert.AreEqual(2000, occurrences.Count);
        }
        public void Occurrences_crossing_start()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule { Frequency = 7 };
            IList<DateTime> occurrences = Convert(year.GetOccurrences(_start, new DateTime(1970, 1, 1), new DateTime(1990, 11, 3)));

            Assert.AreEqual(2, occurrences.Count);
            Assert.AreEqual(new DateTime(1983, 11, 3), occurrences[0]);
            Assert.AreEqual(new DateTime(1990, 11, 3), occurrences[1]);
        }
        public void Occurrences_before_start()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule {
                Frequency = 7
            };
            IList <DateTime> occurrences = Convert(year.GetOccurrences(_start, new DateTime(1900, 1, 1), new DateTime(1950, 1, 1)));

            Assert.AreEqual(0, occurrences.Count);
        }
        public void Occurrences_within_period()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule { Frequency = 7 };
            IList<DateTime> occurrences = Convert(year.GetOccurrences(_start, new DateTime(1985, 3, 1), new DateTime(2005, 1, 1)));

            Assert.AreEqual(3, occurrences.Count);
            Assert.AreEqual(new DateTime(1990, 11, 3), occurrences[0]);
            Assert.AreEqual(new DateTime(1997, 11, 3), occurrences[1]);
            Assert.AreEqual(new DateTime(2004, 11, 3), occurrences[2]);
        }
        public void Occurrences_stress_test()
        {
            var            d    = new DateTime(900, 1, 1);
            YearlySchedule year = new YearlySchedule {
                Frequency = 1
            };

            // 1/1/1900 (Monday) -> 31/12/1999 (Friday) = 36524 total days; 7 days in every 21 for 100 years; 36524 - 14 days = 36510 / 3 = 12170
            IList <DateTime> occurrences = Convert(year.GetOccurrences(d, d, new DateTime(2899, 12, 31)));

            Assert.AreEqual(2000, occurrences.Count);
        }
        public void Occurrences_crossing_start()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule {
                Frequency = 7
            };
            IList <DateTime> occurrences = Convert(year.GetOccurrences(_start, new DateTime(1970, 1, 1), new DateTime(1990, 11, 3)));

            Assert.AreEqual(2, occurrences.Count);
            Assert.AreEqual(new DateTime(1983, 11, 3), occurrences[0]);
            Assert.AreEqual(new DateTime(1990, 11, 3), occurrences[1]);
        }
        public void Occurrences_with_time()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule { Frequency = 7 };
            IList<DateTime> occurrences = Convert(year.GetOccurrences(
                new DateTime(1983, 11, 3, 18, 0, 0),
                new DateTime(2004, 11, 3, 14, 0, 0),
                new DateTime(2015, 12, 31)));

            Assert.AreEqual(2, occurrences.Count);
            Assert.AreEqual(new DateTime(2004, 11, 3, 18, 0, 0), occurrences[0]);
            Assert.AreEqual(new DateTime(2011, 11, 3, 18, 0, 0), occurrences[1]);
        }
        public void Occurrences_within_period()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule {
                Frequency = 7
            };
            IList <DateTime> occurrences = Convert(year.GetOccurrences(_start, new DateTime(1985, 3, 1), new DateTime(2005, 1, 1)));

            Assert.AreEqual(3, occurrences.Count);
            Assert.AreEqual(new DateTime(1990, 11, 3), occurrences[0]);
            Assert.AreEqual(new DateTime(1997, 11, 3), occurrences[1]);
            Assert.AreEqual(new DateTime(2004, 11, 3), occurrences[2]);
        }
        public void Occurrences_with_time()
        {
            // 3/11/1983, 3/11/1990, 3/11/1997, 3/11/2004, 3/11/2011, 3/11/2018, 3/11/2026
            YearlySchedule year = new YearlySchedule {
                Frequency = 7
            };
            IList <DateTime> occurrences = Convert(year.GetOccurrences(
                                                       new DateTime(1983, 11, 3, 18, 0, 0),
                                                       new DateTime(2004, 11, 3, 14, 0, 0),
                                                       new DateTime(2015, 12, 31)));

            Assert.AreEqual(2, occurrences.Count);
            Assert.AreEqual(new DateTime(2004, 11, 3, 18, 0, 0), occurrences[0]);
            Assert.AreEqual(new DateTime(2011, 11, 3, 18, 0, 0), occurrences[1]);
        }