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 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 RollForwardThroughUpdate() { 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.RollBackToStart(); storage.RollForwardTo(new TimeMarker(2)); Assert.That( storage, Is.EquivalentTo(new int[] { 0, 1, 2, 3, 4, maximumValue, 6, 7, 8, 9 })); }
public void RollForwardThroughClear() { 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.RollBackToStart(); storage.RollForwardTo(new TimeMarker(2)); Assert.That( storage, Is.EquivalentTo(new int[] { maximumValue + 1 })); }
public void RollBackToStartWithNoValues() { var storage = new ListHistory <int>(); Assert.DoesNotThrow(() => storage.RollBackToStart()); }