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); }
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); }
public IEnumerable <DateTime> GetDatesInRange(DateRange dateRange) => dateRange.AllDatesInRange();