Ejemplo n.º 1
0
		public void TestDuplicates()
		{
			SnapshotHistory<double> h = new SnapshotHistory<double>(TimeSpan.FromSeconds(1000.0));
			h.AddSnapshot(0.0, 0.0);
			h.AddSnapshot(1.0, 1.0);
			h.AddSnapshot(2.0, 2.0);

			Assert.AreEqual(1.0, h.GetNext(h.GetSnapshotBefore(0.0)).Value.Value, "next to first is second with 1.0");

			h.AddSnapshot(5.0, 1.0);

			Assert.AreEqual(5.0, h.GetNext(h.GetSnapshotBefore(0.0)).Value.Value, "next to first is second with 5.0 (after we added a duplicate)");

			Assert.AreEqual(2.0, h.GetNext(h.GetNext(h.GetSnapshotBefore(0.0)).Value).Value.Value, "last is still 2.0 (didn't keep the 1.0,1.0)");
		}
Ejemplo n.º 2
0
        public void TestDuplicates()
        {
            SnapshotHistory <double> h = new SnapshotHistory <double>(TimeSpan.FromSeconds(1000.0));

            h.AddSnapshot(0.0, 0.0);
            h.AddSnapshot(1.0, 1.0);
            h.AddSnapshot(2.0, 2.0);

            Assert.AreEqual(1.0, h.GetNext(h.GetSnapshotBefore(0.0)).Value.Value, "next to first is second with 1.0");

            h.AddSnapshot(5.0, 1.0);

            Assert.AreEqual(5.0, h.GetNext(h.GetSnapshotBefore(0.0)).Value.Value, "next to first is second with 5.0 (after we added a duplicate)");

            Assert.AreEqual(2.0, h.GetNext(h.GetNext(h.GetSnapshotBefore(0.0)).Value).Value.Value, "last is still 2.0 (didn't keep the 1.0,1.0)");
        }
Ejemplo n.º 3
0
        public void TestGetNext()
        {
            SnapshotHistory <int> h = new SnapshotHistory <int>(TimeSpan.FromSeconds(1000.0));

            h.AddSnapshot(1, 0.0);

            h.AddSnapshot(2, 1.0);

            h.AddSnapshot(3, 2.0);

            var s = h.GetClosestSnapshot(0.0);

            Assert.AreEqual(1, s.Value, "get first with closest");
            s = h.GetNext(s).Value;
            Assert.AreEqual(2, s.Value, "next to first is second");
            s = h.GetNext(s).Value;
            Assert.AreEqual(3, s.Value, "next to second is third");
            Assert.False(h.GetNext(s).HasValue, "next to last is null");

            Assert.AreEqual(3, h.GetNext(h.GetClosestSnapshot(1.0)).Value.Value, "next to closest to second is third");
        }
Ejemplo n.º 4
0
		public void TestGetNext()
		{
			SnapshotHistory<int> h = new SnapshotHistory<int>(TimeSpan.FromSeconds(1000.0));

			h.AddSnapshot(1, 0.0);

			h.AddSnapshot(2, 1.0);

			h.AddSnapshot(3, 2.0);

			var s = h.GetClosestSnapshot(0.0);
			Assert.AreEqual(1, s.Value, "get first with closest");
			s = h.GetNext(s).Value;
			Assert.AreEqual(2, s.Value, "next to first is second");
			s = h.GetNext(s).Value;
			Assert.AreEqual(3, s.Value, "next to second is third");
			Assert.False(h.GetNext(s).HasValue, "next to last is null");

			Assert.AreEqual(3, h.GetNext(h.GetClosestSnapshot(1.0)).Value.Value, "next to closest to second is third");
		}