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)"); }
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)"); }
public void TestBefore() { SnapshotHistory<int> h = new SnapshotHistory<int>(TimeSpan.FromSeconds(1000.0)); h.AddSnapshot(1, 1.0); Assert.AreEqual(1, h.GetSnapshotBefore(2.0).Value, "first element with one element(1.0) and t=2"); Assert.AreEqual(1, h.GetSnapshotBefore(1.0).Value, "first element with one element(1.0) and t=1"); Assert.AreEqual(1, h.GetSnapshotBefore(0.0).Value, "gives first element when given time before the first snapshot"); h.AddSnapshot(2, 2.0); Assert.AreEqual(2, h.GetSnapshotBefore(5.0).Value, "second element before with 2 elements(1.0,2.0) and t=5"); Assert.AreEqual(2, h.GetSnapshotBefore(2.0).Value, "second element before with 2 elements(1.0,2.0) and t=2"); Assert.AreEqual(1, h.GetSnapshotBefore(1.0).Value, "first element before with 2 elements(1.0,2.0) and t=1"); Assert.AreEqual(1, h.GetSnapshotBefore(0.0).Value, "gives first element when given time before the first snapshot (2 elements)"); h.AddSnapshot(5, 5.0); Assert.AreEqual(5, h.GetSnapshotBefore(7.0).Value, "third element before with 3 elements(1.0,2.0,5.0) and t=7"); Assert.AreEqual(5, h.GetSnapshotBefore(5.0).Value, "third element before with 3 elements(1.0,2.0,5.0) and t=5"); Assert.AreEqual(2, h.GetSnapshotBefore(2.0).Value, "second element before with 3 elements(1.0,2.0,5.0) and t=2"); Assert.AreEqual(1, h.GetSnapshotBefore(1.5).Value, "first element before with 3 elements(1.0,2.0,5.0) and t=1"); Assert.AreEqual(1, h.GetSnapshotBefore(1.0).Value, "first element before with 3 elements(1.0,2.0,5.0) and t=1.5"); Assert.AreEqual(1, h.GetSnapshotBefore(0.0).Value, "gives first element when given time before the first snapshot (3 elements)"); }
public void TestBefore() { SnapshotHistory <int> h = new SnapshotHistory <int>(TimeSpan.FromSeconds(1000.0)); h.AddSnapshot(1, 1.0); Assert.AreEqual(1, h.GetSnapshotBefore(2.0).Value, "first element with one element(1.0) and t=2"); Assert.AreEqual(1, h.GetSnapshotBefore(1.0).Value, "first element with one element(1.0) and t=1"); Assert.AreEqual(1, h.GetSnapshotBefore(0.0).Value, "gives first element when given time before the first snapshot"); h.AddSnapshot(2, 2.0); Assert.AreEqual(2, h.GetSnapshotBefore(5.0).Value, "second element before with 2 elements(1.0,2.0) and t=5"); Assert.AreEqual(2, h.GetSnapshotBefore(2.0).Value, "second element before with 2 elements(1.0,2.0) and t=2"); Assert.AreEqual(1, h.GetSnapshotBefore(1.0).Value, "first element before with 2 elements(1.0,2.0) and t=1"); Assert.AreEqual(1, h.GetSnapshotBefore(0.0).Value, "gives first element when given time before the first snapshot (2 elements)"); h.AddSnapshot(5, 5.0); Assert.AreEqual(5, h.GetSnapshotBefore(7.0).Value, "third element before with 3 elements(1.0,2.0,5.0) and t=7"); Assert.AreEqual(5, h.GetSnapshotBefore(5.0).Value, "third element before with 3 elements(1.0,2.0,5.0) and t=5"); Assert.AreEqual(2, h.GetSnapshotBefore(2.0).Value, "second element before with 3 elements(1.0,2.0,5.0) and t=2"); Assert.AreEqual(1, h.GetSnapshotBefore(1.5).Value, "first element before with 3 elements(1.0,2.0,5.0) and t=1"); Assert.AreEqual(1, h.GetSnapshotBefore(1.0).Value, "first element before with 3 elements(1.0,2.0,5.0) and t=1.5"); Assert.AreEqual(1, h.GetSnapshotBefore(0.0).Value, "gives first element when given time before the first snapshot (3 elements)"); }