public void RollForwardWithLocalChange() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 1; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)i)); } storage.RollBackToStart(); storage.Add(maximumValue + 1); for (int i = 1; i < maximumValue; i++) { storage.RollForwardTo(new TimeMarker((ulong)i)); Assert.AreEqual(i, storage.Count); for (int j = 1; j <= i; j++) { Assert.IsTrue(storage.Contains(j)); } } }
public void ClearVoidsForwardStack() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { storage.Add(i); } storage.StoreCurrent(new TimeMarker(1)); storage[5] = maximumValue; storage.StoreCurrent(new TimeMarker(2)); storage.RollBackTo(new TimeMarker(1)); storage.Clear(); storage.Add(maximumValue + 1); storage.StoreCurrent(new TimeMarker(3)); storage.RollForwardTo(new TimeMarker(2)); Assert.That( storage, Is.EquivalentTo(new int[] { maximumValue + 1 })); }
public void UpdateClearsForwardStack() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { storage.Add(i); } storage.StoreCurrent(new TimeMarker(1)); storage[5] = maximumValue; storage.StoreCurrent(new TimeMarker(2)); storage.RollBackTo(new TimeMarker(1)); storage[9] = maximumValue; storage.StoreCurrent(new TimeMarker(3)); storage.RollForwardTo(new TimeMarker(2)); Assert.That( storage, Is.EquivalentTo(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, maximumValue })); }
public void RollBackThroughClear() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { storage.Add(i); } storage.StoreCurrent(new TimeMarker(1)); storage.Clear(); storage.Add(maximumValue + 1); storage.StoreCurrent(new TimeMarker(2)); storage.RollBackTo(new TimeMarker(1)); Assert.That( storage, Is.EquivalentTo(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 })); }
public void RollBackToStart() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } storage.RollBackToStart(); Assert.That( storage, Is.EquivalentTo(new int[0])); }
public void RollForwardPastLastValue() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } storage.RollBackTo(new TimeMarker(6)); storage.RollForwardTo(new TimeMarker((ulong)(maximumValue + 1))); Assert.That( storage, Is.EquivalentTo(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 })); }
public void RollBackPastLastSnapshot() { var storage = new ListHistory <int>(); int maximumValue = 30; for (int i = 0; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } // The snapshot is at 20 storage.RollBackTo(new TimeMarker(16)); Assert.That( storage, Is.EquivalentTo( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 })); }
public void RollBackToLastSnapshot() { var storage = new ListHistory <int>(); int maximumValue = 30; for (int i = 0; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } // The first snapshot is at 1, the next one is 20 further so it is at 20 storage.RollBackTo(new TimeMarker(21)); Assert.That( storage, Is.EquivalentTo( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 })); }
public void RollForwardToPastNextSnapshot() { var storage = new ListHistory <int>(); int maximumValue = 30; for (int i = 0; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } // The snapshot is at 21 storage.RollBackTo(new TimeMarker(16)); storage.RollForwardTo(new TimeMarker(26)); Assert.That( storage, Is.EquivalentTo(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 })); }
public void RollBackMultipleTimes() { var storage = new ListHistory <int>(); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { storage.Add(i); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } for (int i = maximumValue; i > 0; i--) { storage.RollBackTo(new TimeMarker((ulong)i)); Assert.AreEqual(i, storage.Count); for (int j = 1; j <= i; j++) { Assert.IsTrue(storage.Contains(j - 1)); } } }