public void OccurrenceWeek()
        {
            TemporalExpression te = new TEInterval(new DateTime(2010, 6, 1), 1, IntervalPrecision.Weeks);

            List<DateTime> dates = te.Occurrences(new DateTime(2010, 6, 1), new DateTime(2011, 6, 5), IntervalPrecision.Weeks);
            Assert.AreEqual(53, dates.Count);
            Assert.AreEqual(new DateTime(2010, 6, 1, 0, 0, 0), dates[0]);
            Assert.AreEqual(new DateTime(2011, 5, 31, 0, 0, 0), dates[52]);

            List<DateTime> dates2 = te.Occurrences(new DateTime(2010, 6, 1), 12, IntervalPrecision.Weeks);
            Assert.AreEqual(12, dates2.Count);
            Assert.AreEqual(new DateTime(2010, 6, 1, 0, 0, 0), dates2[0]);
            Assert.AreEqual(new DateTime(2010, 8, 17, 0, 0, 0), dates2[11]);
        }
        public void ComplexExpressions()
        {
            TemporalExpression te;
            te = (new TEWeekDay(DayOfWeek.Tuesday) | new TEWeekDay(DayOfWeek.Friday));
            te &= new TEInterval(new DateTime(2010, 6, 1), 2, IntervalPrecision.Weeks);

            Assert.IsTrue(te.Includes(new DateTime(2010,6,1)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 4)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 15)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 18)));

            Assert.IsFalse(te.Includes(new DateTime(2010, 6, 8)));
            Assert.IsFalse(te.Includes(new DateTime(2010, 6, 11)));
            Assert.IsFalse(te.Includes(new DateTime(2010, 6, 10)));
            Assert.IsFalse(te.Includes(new DateTime(2010, 6, 16)));
        }
        public void TE_Interval()
        {
            //seconds interval
            TEInterval tis = new TEInterval(new DateTime(2010, 6, 1, 0, 0, 1), 5, IntervalPrecision.Seconds);
            Assert.IsTrue(tis.Includes(new DateTime(2010, 6, 3,0,0,6)));
            Assert.IsTrue(tis.Includes(new DateTime(2010, 6, 3, 0, 0, 11)));
            Assert.IsTrue(tis.Includes(new DateTime(2011, 6, 3, 0, 0, 11)));
            Assert.IsTrue(tis.Includes(new DateTime(2011, 7, 7, 7, 9, 11)));

            Assert.IsFalse(tis.Includes(new DateTime(2010, 6, 3, 0, 0, 7)));
            Assert.IsFalse(tis.Includes(new DateTime(2010, 6, 3, 0, 0, 4)));
            Assert.IsFalse(tis.Includes(new DateTime(2011, 6, 3, 0, 0, 10)));
            Assert.IsFalse(tis.Includes(new DateTime(2011, 7, 7, 7, 9, 20)));

            //minutes interval
            TEInterval tim = new TEInterval(new DateTime(2010, 6, 1, 0, 0, 0), 5, IntervalPrecision.Minutes);
            Assert.IsTrue(tim.Includes(new DateTime(2010, 6, 3, 0, 5, 0)));
            Assert.IsTrue(tim.Includes(new DateTime(2010, 6, 3, 0, 10, 0)));
            Assert.IsTrue(tim.Includes(new DateTime(2011, 6, 3, 0, 25, 0)));
            Assert.IsTrue(tim.Includes(new DateTime(2011, 7, 7, 4, 45, 9)));

            Assert.IsFalse(tim.Includes(new DateTime(2010, 6, 3, 0, 2, 0)));
            Assert.IsFalse(tim.Includes(new DateTime(2010, 6, 3, 0, 11, 0)));
            Assert.IsFalse(tim.Includes(new DateTime(2011, 6, 3, 0, 27, 0)));
            Assert.IsFalse(tim.Includes(new DateTime(2011, 7, 7, 4, 47, 9)));

            //day interval
            TEInterval tid = new TEInterval(new DateTime(2010, 6, 1,5,3,1), 2, IntervalPrecision.Days);
            Assert.IsTrue(tid.Includes(new DateTime(2010, 6, 3)));
            Assert.IsTrue(tid.Includes(new DateTime(2010, 6, 3,8,8,8)));
            Assert.IsTrue(tid.Includes(new DateTime(2010, 7, 1)));

            Assert.IsFalse(tid.Includes(new DateTime(2010, 6, 2)));
            Assert.IsFalse(tid.Includes(new DateTime(2010, 6, 4,5,3,1)));
            Assert.IsFalse(tid.Includes(new DateTime(2010, 6, 6)));
            Assert.IsFalse(tid.Includes(new DateTime(2010, 7, 2)));

            //week interval
            TEInterval tiw = new TEInterval(new DateTime(2010, 6, 1, 5, 3, 1), 3, IntervalPrecision.Weeks);
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 6, 23)));
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 6, 24)));
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 6, 20)));
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 6, 26)));
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 7, 11, 8, 8, 8)));
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 7, 17, 8, 8, 8)));
            Assert.IsTrue(tiw.Includes(new DateTime(2010, 8, 4)));

            Assert.IsFalse(tiw.Includes(new DateTime(2010, 6, 16)));
            Assert.IsFalse(tiw.Includes(new DateTime(2010, 6, 9)));
            Assert.IsFalse(tiw.Includes(new DateTime(2010, 6, 30)));
            Assert.IsFalse(tiw.Includes(new DateTime(2010, 7, 10)));

            //month interval
            TEInterval timo = new TEInterval(new DateTime(2010, 6, 1, 5, 3, 1), 3, IntervalPrecision.Months);
            Assert.IsTrue(timo.Includes(new DateTime(2010, 9, 23)));
            Assert.IsTrue(timo.Includes(new DateTime(2010, 12, 1)));
            Assert.IsTrue(timo.Includes(new DateTime(2011, 6, 5)));
            Assert.IsTrue(timo.Includes(new DateTime(2011, 9, 1,5,3,2)));

            Assert.IsFalse(timo.Includes(new DateTime(2010, 10, 23)));
            Assert.IsFalse(timo.Includes(new DateTime(2011, 1, 4)));
            Assert.IsFalse(timo.Includes(new DateTime(2010, 11, 23,1,1,1)));

            //quarter interval
            //TEInterval tiq = new TEInterval(new DateTime(2010, 6, 1, 5, 3, 1), 2, IntervalPrecision.Quarters);
            //Assert.IsTrue(tiq.Includes(new DateTime(2010, 12, 23)));
            //Assert.IsTrue(tiq.Includes(new DateTime(2010, 12, 1)));
            //Assert.IsTrue(tiq.Includes(new DateTime(2011, 6, 5)));
            //Assert.IsTrue(tiq.Includes(new DateTime(2011, 6, 1, 5, 3, 2)));

            //Assert.IsFalse(tiq.Includes(new DateTime(2010, 11, 23)));
            //Assert.IsFalse(tiq.Includes(new DateTime(2010, 11, 1)));
            //Assert.IsFalse(tiq.Includes(new DateTime(2011, 8, 5)));
            //Assert.IsFalse(tiq.Includes(new DateTime(2011, 5, 1, 5, 3, 2)));

            //year interval
            TEInterval tiy = new TEInterval(new DateTime(2010, 6, 1, 5, 3, 1), 2, IntervalPrecision.Years);
            Assert.IsTrue(tiy.Includes(new DateTime(2012, 12, 23)));
            Assert.IsTrue(tiy.Includes(new DateTime(2012, 12, 7)));
            Assert.IsTrue(tiy.Includes(new DateTime(2014, 6, 5)));
            Assert.IsTrue(tiy.Includes(new DateTime(2016, 6, 1, 5, 3, 2)));

            Assert.IsFalse(tiy.Includes(new DateTime(2011, 12, 23)));
            Assert.IsFalse(tiy.Includes(new DateTime(2013, 12, 23)));
            Assert.IsFalse(tiy.Includes(new DateTime(2015, 6, 1, 5, 3, 2)));
        }