예제 #1
0
        public void OccurrenceSecond()
        {
            TemporalExpression te = new TESecond(45);
            List<DateTime> dates = te.Occurrences(new DateTime(2010, 6, 1), new DateTime(2010, 6, 2), IntervalPrecision.Seconds);
            Assert.AreEqual(1440, dates.Count);
            Assert.AreEqual(new DateTime(2010, 6, 1, 0, 0, 45), dates[0]);
            Assert.AreEqual(new DateTime(2010, 6, 1, 23, 59, 45), dates[1439]);

            List<DateTime> dates2 = te.Occurrences(new DateTime(2010, 6, 1), 720, IntervalPrecision.Seconds);
            Assert.AreEqual(720, dates2.Count);
            Assert.AreEqual(new DateTime(2010, 6, 1, 0, 0, 45), dates2[0]);
            Assert.AreEqual(new DateTime(2010, 6, 1, 11, 59, 45), dates2[719]);
        }
예제 #2
0
        public void TE_Second()
        {
            //seconds value
            TESecond te = new TESecond(20);
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 5, 1, 1, 20)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 5, 5, 1, 20)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 5, 1, 7, 20)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 8, 1, 30, 20)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 9, 5, 1, 1, 20)));
            Assert.IsTrue(te.Includes(new DateTime(2011, 6, 5, 1, 1, 20)));

            Assert.IsFalse(te.Includes(new DateTime(2010, 6, 5, 2, 1, 1)));
            Assert.IsFalse(te.Includes(new DateTime(2010, 6, 5, 2, 1, 29)));

            //seconds range
            TESecond ter = new TESecond(20,40);
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 5, 1, 1, 20)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 5, 5, 1, 21)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 5, 1, 7, 22)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 8, 1, 30, 30)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 9, 5, 1, 1, 35)));
            Assert.IsTrue(ter.Includes(new DateTime(2011, 6, 5, 1, 1, 40)));

            Assert.IsFalse(ter.Includes(new DateTime(2010, 6, 5, 2, 1, 19)));
            Assert.IsFalse(ter.Includes(new DateTime(2010, 6, 5, 2, 1, 41)));

            TESecond ter2 = new TESecond(40, 5);
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 5, 1, 1, 40)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 5, 5, 1, 41)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 5, 1, 7, 50)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 8, 1, 30, 55)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 9, 5, 1, 1, 1)));
            Assert.IsTrue(ter2.Includes(new DateTime(2011, 6, 5, 1, 1, 5)));

            Assert.IsFalse(ter2.Includes(new DateTime(2010, 6, 5, 2, 1, 39)));
            Assert.IsFalse(ter2.Includes(new DateTime(2010, 6, 5, 2, 1, 6)));
            Assert.IsFalse(ter2.Includes(new DateTime(2010, 6, 5, 2, 1, 20)));
        }