예제 #1
0
        public void CountSteps_1Year()
        {
            TSDateCalculator.TimeStepUnitCode u = TSDateCalculator.TimeStepUnitCode.Year;
            short q = 1;

            DateTime d1 = new DateTime(1960, 1, 2);
            DateTime d2 = new DateTime(1980, 12, 15);
            int      n  = TSDateCalculator.CountSteps(d1, d2, u, q);

            Assert.AreEqual(20, n);

            n = TSDateCalculator.CountSteps(d1, d1, u, q);
            Assert.AreEqual(0, n);
        }
예제 #2
0
        public void CountSteps_4Week()
        {
            TSDateCalculator.TimeStepUnitCode u = TSDateCalculator.TimeStepUnitCode.Week;
            short q = 4;

            DateTime d1 = new DateTime(1960, 1, 1);
            DateTime d2 = d1.AddDays(56);
            int      n  = TSDateCalculator.CountSteps(d1, d2, u, q);

            Assert.AreEqual(2, n);

            n = TSDateCalculator.CountSteps(d1, d1, u, q);
            Assert.AreEqual(0, n);
        }
예제 #3
0
        public void CountSteps_5Min()
        {
            TSDateCalculator.TimeStepUnitCode u = TSDateCalculator.TimeStepUnitCode.Minute;
            short q = 5;

            DateTime d1 = new DateTime(1960, 1, 15);
            DateTime d2 = new DateTime(1960, 1, 17);
            int      n  = TSDateCalculator.CountSteps(d1, d2, u, q);

            Assert.AreEqual(576, n);

            d1 = d1.AddSeconds(98);
            n  = TSDateCalculator.CountSteps(d1, d2, u, q);
            Assert.AreEqual(576, n);

            n = TSDateCalculator.CountSteps(d1, d1, u, q);
            Assert.AreEqual(0, n);
        }
예제 #4
0
        public void CountSteps_2Month()
        {
            TSDateCalculator.TimeStepUnitCode u = TSDateCalculator.TimeStepUnitCode.Month;
            short q = 2;

            DateTime d1 = new DateTime(1960, 1, 2);
            DateTime d2 = new DateTime(1960, 12, 15);
            int      n  = TSDateCalculator.CountSteps(d1, d2, u, q);

            Assert.AreEqual(6, n);

            d1 = new DateTime(1960, 1, 1);
            d2 = new DateTime(1960, 12, 1);
            n  = TSDateCalculator.CountSteps(d1, d2, u, q);
            Assert.AreEqual(6, n);

            n = TSDateCalculator.CountSteps(d1, d1, u, q);
            Assert.AreEqual(0, n);
        }
예제 #5
0
        public void CountSteps_2Day()
        {
            TSDateCalculator.TimeStepUnitCode u = TSDateCalculator.TimeStepUnitCode.Day;
            short q = 2;

            DateTime d1 = new DateTime(1960, 1, 1);
            DateTime d2 = new DateTime(1960, 12, 31);
            int      n  = TSDateCalculator.CountSteps(d1, d2, u, q);

            Assert.AreEqual(183, n);

            d1 = d1.AddHours(23).AddMinutes(59);
            d2 = new DateTime(1961, 12, 31);
            n  = TSDateCalculator.CountSteps(d1, d2, u, q);
            Assert.AreEqual(365, n);

            n = TSDateCalculator.CountSteps(d1, d1, u, q);
            Assert.AreEqual(0, n);
        }
예제 #6
0
        public void CountSteps_2Hour()
        {
            TSDateCalculator.TimeStepUnitCode u = TSDateCalculator.TimeStepUnitCode.Hour;
            short q = 2;

            DateTime d1 = new DateTime(1960, 2, 20);
            DateTime d2 = new DateTime(1960, 3, 3);
            int      n  = TSDateCalculator.CountSteps(d1, d2, u, q);

            Assert.AreEqual(144, n);

            d2 = d1.AddHours(6);
            d1 = d1.AddMinutes(30);
            n  = TSDateCalculator.CountSteps(d1, d2, u, q);
            Assert.AreEqual(3, n);

            n = TSDateCalculator.CountSteps(d1, d1, u, q);
            Assert.AreEqual(0, n);
        }