Exemplo n.º 1
0
        public void AllDatesInRange_should_return_one_result_if_the_date_range_covers_one_day()
        {
            var dateRange = new DateRange(start: new DateTime(2020, 1, 1), end: new DateTime(2020, 1, 1));
            var dates     = dateRange.AllDatesInRange().ToList();

            Assert.Contains(new DateTime(2020, 1, 1), dates);
            Assert.Single(dates);
        }
Exemplo n.º 2
0
        public void AllDatesInRange_should_return_all_dates_within_a_given_range()
        {
            var dateRange = new DateRange(start: new DateTime(2020, 1, 1), end: new DateTime(2020, 1, 5));
            var dates     = dateRange.AllDatesInRange().ToList();

            Assert.Contains(new DateTime(2020, 1, 1), dates);
            Assert.Contains(new DateTime(2020, 1, 2), dates);
            Assert.Contains(new DateTime(2020, 1, 3), dates);
            Assert.Contains(new DateTime(2020, 1, 4), dates);
            Assert.Contains(new DateTime(2020, 1, 5), dates);
            Assert.Equal(5, dates.Count);

            dateRange = new DateRange(start: new DateTime(2019, 12, 28), end: new DateTime(2020, 1, 2));
            dates     = dateRange.AllDatesInRange().ToList();
            Assert.Contains(new DateTime(2019, 12, 28), dates);
            Assert.Contains(new DateTime(2019, 12, 29), dates);
            Assert.Contains(new DateTime(2019, 12, 30), dates);
            Assert.Contains(new DateTime(2019, 12, 31), dates);
            Assert.Contains(new DateTime(2020, 1, 1), dates);
            Assert.Contains(new DateTime(2020, 1, 2), dates);
            Assert.Equal(6, dates.Count);
        }
Exemplo n.º 3
0
 public IEnumerable <DateTime> GetDatesInRange(DateRange dateRange) =>
 dateRange.AllDatesInRange();