public void temporal_expression_difference_matches_expected_dates() { // include april through september excluding June var te = new TemporalExpressionDifference(new RangeInYear(4, 1, 9, 30), new RangeInYear(6, 1, 6, 30)); var includedDt = DateTime.SpecifyKind(new DateTime(2016, 05, 09), DateTimeKind.Utc); var excludedDt = DateTime.SpecifyKind(new DateTime(2016, 06, 13), DateTimeKind.Utc); Assert.That(te.Includes(includedDt)); Assert.That(te.Includes(excludedDt), Is.False); }
public void date_in_generates_dates_in_temporal_expression() { // create a temporal expression over the first week of january excluding weekend days var te = new TemporalExpressionDifference(new RangeInYear(1, 1, 1, 7), new TemporalExpressionSequence(new[] { new DayInMonth(0, 0), new DayInMonth(6, 0), })); // Apply this to a date range over the first full week of January. var firstDt = DateTime.SpecifyKind(new DateTime(2016, 01, 01), DateTimeKind.Utc); var lastDt = DateTime.SpecifyKind(new DateTime(2016, 01, 08), DateTimeKind.Utc); var lastDtInRange = lastDt - TimeSpan.FromDays(1); var included = te.DatesIn(new DateRange(firstDt, lastDt)).ToList(); var count = included.Count(); //foreach (var item in included) //{ // Console.WriteLine(item); //} // test a couple of things about the output // First entry should be a Friday Assert.That(included.First(), Is.EqualTo(firstDt)); Assert.That(included.First().WeekDayIndex(), Is.EqualTo(firstDt.WeekDayIndex())); // Last day is a Thursday Assert.That(included.Last(), Is.EqualTo(lastDtInRange)); Assert.That(included.Last().WeekDayIndex(), Is.EqualTo(lastDtInRange.WeekDayIndex())); // should be five days Assert.That(count, Is.EqualTo(5)); }