Exemplo n.º 1
0
        public void TimeList_TimeUpdateStart_NotFromZero()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now.AddSeconds(10));
            Assert.AreEqual(list.SecondsAt(0), 0);

            list.Add(22, now.AddSeconds(14));
            Assert.AreEqual(list.SecondsAt(0), 4);
            Assert.AreEqual(list.SecondsAt(1), 0);

            list.Add(22, now.AddSeconds(15));
            Assert.AreEqual(list.SecondsAt(0), 4);
            Assert.AreEqual(list.SecondsAt(1), 1);

            list.Add(33, now.AddSeconds(17));
            Assert.AreEqual(list.SecondsAt(0), 4);
            Assert.AreEqual(list.SecondsAt(1), 3);
            Assert.AreEqual(list.SecondsAt(2), 0);
        }
Exemplo n.º 2
0
        public void TimeList_CorrectTimeSimple()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now);
            Assert.AreEqual(list.SecondsAt(0), 0);

            list.Add(22, now.AddSeconds(3));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 0);

            list.Add(33, now.AddSeconds(7));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 0);

            list.Add(44, now.AddSeconds(17));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 10);
            Assert.AreEqual(list.SecondsAt(3), 0);

            list.Add(55, now.AddSeconds(18));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 10);
            Assert.AreEqual(list.SecondsAt(3), 1);
            Assert.AreEqual(list.SecondsAt(4), 0);

            list.Add(66, now.AddSeconds(21));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 10);
            Assert.AreEqual(list.SecondsAt(3), 1);
            Assert.AreEqual(list.SecondsAt(4), 3);
            Assert.AreEqual(list.SecondsAt(5), 0);

            Assert.AreEqual(list.Count, 6);
        }
Exemplo n.º 3
0
        public void TimeList_TimeUpdate()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now);
            Assert.AreEqual(list.SecondsAt(0), 0);

            list.Add(11, now.AddSeconds(5));
            Assert.AreEqual(list.SecondsAt(0), 5);

            list.Add(11, now.AddSeconds(6));
            Assert.AreEqual(list.SecondsAt(0), 6);

            list.Add(11, now.AddSeconds(9));
            Assert.AreEqual(list.SecondsAt(0), 9);

            list.Add(22, now.AddSeconds(15));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 0);

            list.Add(22, now.AddSeconds(16));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 1);

            list.Add(22, now.AddSeconds(20));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 5);

            list.Add(33, now.AddSeconds(26));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 11);
            Assert.AreEqual(list.SecondsAt(2), 0);
        }