コード例 #1
0
        public void MillisIndexToTimeTest()
        {
            var t = new MillisTimeUtils();

            Assert.AreEqual(402, t.IndexToTime(2, 4, 10000));
            Assert.AreEqual(0, t.IndexToTime(0, 0, 10000));

            var oneDay = TimeSpan.FromDays(1).TotalMilliseconds;

            Assert.AreEqual(oneDay + 400, t.IndexToTime((long)oneDay, 4, 10000));
        }
コード例 #2
0
        public void HugeNumbersMillisTimeTest()
        {
            var t = new MillisTimeUtils();

            var frequency = 25 * 1000 * 1000;

            var oneWeek = (long)TimeSpan.FromDays(7).TotalMilliseconds;

            var indexAtOneWeek = t.TimeToIndex(0, oneWeek, frequency);

            var timeFromIndex = t.IndexToTime(0, indexAtOneWeek, frequency);

            var time = TimeSpan.FromMilliseconds(timeFromIndex);

            Assert.AreEqual(TimeSpan.FromDays(7), time);
        }
コード例 #3
0
        public void BigNumbersMillisTimeTest()
        {
            var t = new MillisTimeUtils();

            var oneDay = (long)TimeSpan.FromDays(1).TotalMilliseconds;

            var indexAtOneDay = t.TimeToIndex(oneDay, oneDay, 1000 * 1000);

            var timeFromIndex = t.IndexToTime(0, indexAtOneDay, 1000 * 1000);

            var time = TimeSpan.FromMilliseconds(timeFromIndex);

            Assert.AreEqual(TimeSpan.Zero, time);

            indexAtOneDay = t.TimeToIndex(0, oneDay, 1000 * 1000);

            timeFromIndex = t.IndexToTime(oneDay, indexAtOneDay, 1000 * 1000);

            time = TimeSpan.FromMilliseconds(timeFromIndex);

            Assert.AreEqual(TimeSpan.FromDays(2), time);
        }