public void RollBackFromDeathPastCreation() { 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.RollBackTo(new TimeMarker(0))); Assert.IsFalse(timeline.IsAlive()); Assert.IsNull(timeline.Object); }
public void AddToTimeline() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); Assert.IsFalse(timeline.IsAlive()); timeline.AddToTimeline(); var marker = new TimeMarker(1); timeline.Mark(marker); Assert.IsTrue(timeline.IsAlive()); Assert.AreEqual(marker, timeline.CreationTime); Assert.IsNull(timeline.DeletionTime); var obj = timeline.Object; Assert.AreEqual(0, obj.SomeValue); Assert.AreEqual(0, obj.LotsOfValues.Count); }
public void RollForwardFromBeforeCreationToPastDeath() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); var creationTime = new TimeMarker(2); timeline.AddToTimeline(); timeline.Mark(creationTime); var deletionTime = new TimeMarker(3); timeline.DeleteFromTimeline(); timeline.Mark(deletionTime); timeline.RollBackTo(new TimeMarker(1)); Assert.IsFalse(timeline.IsAlive()); Assert.IsNull(timeline.Object); timeline.RollForwardTo(new TimeMarker(4)); 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 })); }
public void RollBackToBeforeBeginning() { var id = new HistoryId(); var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject); var creationTime = new TimeMarker(1); timeline.AddToTimeline(); timeline.Mark(creationTime); int maximumValue = 10; for (int i = 0; i < maximumValue; i++) { timeline.Object.SomeValue = i; timeline.Object.LotsOfValues.Add(i); timeline.Mark(new TimeMarker((ulong)(i + 2))); } timeline.RollBackTo(new TimeMarker(0)); Assert.IsFalse(timeline.IsAlive()); Assert.IsNull(timeline.Object); }