public void MarkClearsForwardHistory() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); timeline.AddToTimeline(); timeline.Mark(new TimeMarker(2)); timeline.Object.SomeValue = 1; timeline.Object.LotsOfValues.Add(2); timeline.Mark(new TimeMarker(3)); timeline.DeleteFromTimeline(); timeline.Mark(new TimeMarker(4)); timeline.RollBackTo(new TimeMarker(2)); timeline.Object.SomeValue = 2; timeline.Object.LotsOfValues.Add(3); timeline.Mark(new TimeMarker(3)); timeline.RollForwardTo(new TimeMarker(10)); Assert.AreEqual(2, timeline.Object.SomeValue); Assert.That( timeline.Object.LotsOfValues, Is.EquivalentTo(new int[] { 3 })); }
public void CreateClearsForwardHistory() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); timeline.AddToTimeline(); timeline.Mark(new TimeMarker(2)); timeline.Object.SomeValue = 1; timeline.Object.LotsOfValues.Add(2); timeline.Mark(new TimeMarker(3)); timeline.DeleteFromTimeline(); timeline.Mark(new TimeMarker(4)); timeline.RollBackTo(new TimeMarker(0)); timeline.AddToTimeline(); timeline.Mark(new TimeMarker(1)); timeline.RollForwardTo(new TimeMarker(10)); Assert.IsTrue(timeline.IsAlive()); Assert.AreEqual(new TimeMarker(1), timeline.CreationTime); Assert.IsNull(timeline.DeletionTime); Assert.AreEqual(0, timeline.Object.SomeValue); Assert.AreEqual(0, timeline.Object.LotsOfValues.Count); }
public void RollForwardWithLocalChange() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); var creationTime = new TimeMarker(1); timeline.AddToTimeline(); timeline.Mark(creationTime); timeline.Object.SomeValue = 1; timeline.Object.LotsOfValues.Add(2); timeline.Mark(new TimeMarker(2)); timeline.Object.SomeValue = 2; timeline.Object.LotsOfValues.Add(4); timeline.Mark(new TimeMarker(3)); timeline.RollBackTo(new TimeMarker(2)); timeline.Object.SomeValue = 3; timeline.Object.LotsOfValues.Add(8); timeline.RollForwardTo(new TimeMarker(3)); Assert.AreEqual(2, timeline.Object.SomeValue); Assert.That( timeline.Object.LotsOfValues, Is.EquivalentTo(new int[] { 2, 4 })); }
public void RollForwardPastDeath() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); var creationTime = new TimeMarker(1); timeline.AddToTimeline(); timeline.Mark(creationTime); timeline.Object.SomeValue = 1; timeline.Object.LotsOfValues.Add(2); timeline.Mark(new TimeMarker(2)); var deletionTime = new TimeMarker(3); timeline.DeleteFromTimeline(); timeline.Mark(deletionTime); timeline.RollBackTo(new TimeMarker(1)); Assert.IsTrue(timeline.IsAlive()); timeline.RollForwardTo(new TimeMarker(4)); Assert.IsFalse(timeline.IsAlive()); Assert.IsNull(timeline.Object); }
public void RollForwardWhileDead() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); var creationTime = new TimeMarker(1); timeline.AddToTimeline(); timeline.Mark(creationTime); var deletionTime = new TimeMarker(2); timeline.DeleteFromTimeline(); timeline.Mark(deletionTime); Assert.DoesNotThrow(() => timeline.RollForwardTo(new TimeMarker(3))); Assert.IsFalse(timeline.IsAlive()); Assert.IsNull(timeline.Object); }
public void RollForwardToAfterCreation() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); var creationTime = new TimeMarker(2); timeline.AddToTimeline(); timeline.Mark(creationTime); timeline.Object.SomeValue = 1; timeline.Object.LotsOfValues.Add(2); timeline.Mark(new TimeMarker(3)); timeline.RollBackTo(new TimeMarker(1)); Assert.IsFalse(timeline.IsAlive()); timeline.RollForwardTo(new TimeMarker(3)); Assert.AreEqual(1, timeline.Object.SomeValue); Assert.That( timeline.Object.LotsOfValues, Is.EquivalentTo(new int[] { 2 })); }