예제 #1
0
        public void DaysBeforeMakesSense()
        {
            DateTimeRange   range = new DateTimeRange(new DateTime(2019, 5, 1, 12, 1, 1), new DateTime(2019, 5, 7, 14, 1, 1));
            List <DateTime> days  = range.DaysBefore(new DateTime(2019, 5, 3));

            Assert.AreEqual(days.Count, 2);
            Assert.AreEqual(days[0].Ticks, (new DateTime(2019, 5, 1)).Ticks);
            Assert.AreEqual(days[1].Ticks, (new DateTime(2019, 5, 2)).Ticks);

            range = new DateTimeRange(new DateTime(2019, 5, 4, 12, 1, 1), new DateTime(2019, 5, 7, 14, 1, 1));
            days  = range.DaysBefore(new DateTime(2019, 5, 3));
            Assert.AreEqual(days.Count, 0);

            range = new DateTimeRange(new DateTime(2019, 5, 3), new DateTime(2019, 5, 7, 14, 1, 1));
            days  = range.DaysBefore(new DateTime(2019, 5, 3));
            Assert.AreEqual(days.Count, 0);
        }