コード例 #1
0
        public void OccurrenceMinute()
        {
            TemporalExpression te = new TEMinute(45);
            List<DateTime> dates = te.Occurrences(new DateTime(2010, 6, 1), new DateTime(2010, 6, 2), IntervalPrecision.Minutes);
            Assert.AreEqual(24, dates.Count);
            Assert.AreEqual(new DateTime(2010, 6, 1, 0, 45, 0), dates[0]);
            Assert.AreEqual(new DateTime(2010, 6, 1, 23, 45, 0), dates[23]);

            List<DateTime> dates2 = te.Occurrences(new DateTime(2010, 6, 1), 12, IntervalPrecision.Minutes);
            Assert.AreEqual(12, dates2.Count);
            Assert.AreEqual(new DateTime(2010, 6, 1, 0, 45, 0), dates2[0]);
            Assert.AreEqual(new DateTime(2010, 6, 1, 11, 45, 0), dates2[11]);
        }
コード例 #2
0
        public void TE_Minute()
        {
            //minute value
            TEMinute te = new TEMinute(30);
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 5, 1, 30, 1)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 5, 5, 30, 1)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 5, 1, 30, 7)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 6, 8, 1, 30, 1)));
            Assert.IsTrue(te.Includes(new DateTime(2010, 9, 5, 1, 30, 1)));
            Assert.IsTrue(te.Includes(new DateTime(2011, 6, 5, 1, 30, 1)));

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

            //minute range
            TEMinute ter = new TEMinute(30,45);

            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 5, 1, 30, 1)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 5, 5, 31, 1)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 5, 1, 32, 7)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 6, 8, 1, 30, 1)));
            Assert.IsTrue(ter.Includes(new DateTime(2010, 9, 5, 1, 40, 1)));
            Assert.IsTrue(ter.Includes(new DateTime(2011, 6, 5, 1, 30, 1)));

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

            //minute range with start > end
            TEMinute ter2 = new TEMinute(45, 5);

            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 5, 1, 46, 1)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 5, 5, 50, 1)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 5, 1, 1, 7)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 6, 8, 1, 2, 1)));
            Assert.IsTrue(ter2.Includes(new DateTime(2010, 9, 5, 1, 55, 1)));
            Assert.IsTrue(ter2.Includes(new DateTime(2011, 6, 5, 1, 5, 1)));

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