public void RollForwardWithLocalChange() { var objects = new Dictionary <HistoryId, MockHistoryObject>(); Func <HistoryId, MockHistoryObject> lookupFunc = id => objects[id]; var storage = new HistoryObjectListHistory <MockHistoryObject>(lookupFunc); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { var obj = new MockHistoryObject(i); objects.Add(obj.HistoryId, obj); storage.Add(obj); storage.StoreCurrent(new TimeMarker((ulong)(i + 1))); } storage.RollBackToStart(); var newObj = new MockHistoryObject(maximumValue + 1); objects.Add(newObj.HistoryId, newObj); storage.Add(newObj); 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(objects[new HistoryId(j - 1)])); } } }
public void RemoveItems() { var list = new HistoryObjectListHistory <MockHistoryObject>(FromId) { new MockHistoryObject(0), new MockHistoryObject(1), new MockHistoryObject(2), new MockHistoryObject(3), new MockHistoryObject(4), new MockHistoryObject(5), }; list.Remove(new MockHistoryObject(0)); Assert.IsFalse(list.Contains(new MockHistoryObject(0))); list.Remove(new MockHistoryObject(1)); Assert.IsFalse(list.Contains(new MockHistoryObject(1))); list.Remove(new MockHistoryObject(2)); Assert.IsFalse(list.Contains(new MockHistoryObject(2))); list.Remove(new MockHistoryObject(3)); Assert.IsFalse(list.Contains(new MockHistoryObject(3))); list.Remove(new MockHistoryObject(4)); Assert.IsFalse(list.Contains(new MockHistoryObject(4))); list.Remove(new MockHistoryObject(5)); Assert.IsFalse(list.Contains(new MockHistoryObject(5))); }