Exemple #1
0
        public void DeleteClearsForwardHistory()
        {
            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.DeleteFromTimeline();
            timeline.Mark(new TimeMarker(3));

            timeline.RollBackTo(new TimeMarker(2));
            Assert.IsTrue(timeline.IsAlive());
            Assert.AreEqual(new TimeMarker(2), timeline.CreationTime);
            Assert.AreEqual(new TimeMarker(3), timeline.DeletionTime);

            Assert.AreEqual(0, timeline.Object.SomeValue);
            Assert.AreEqual(0, timeline.Object.LotsOfValues.Count);
        }
Exemple #2
0
        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 }));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void RollBackFromDeathToLife()
        {
            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);

            Assert.DoesNotThrow(() => timeline.RollBackTo(new TimeMarker(2)));
            Assert.IsTrue(timeline.IsAlive());
            Assert.IsNotNull(timeline.Object);
            Assert.AreEqual(1, timeline.Object.SomeValue);
            Assert.That(
                timeline.Object.LotsOfValues,
                Is.EquivalentTo(new int[] { 2 }));
        }
Exemple #5
0
        public void DeleteFromTimelineWhileNotCreated()
        {
            var id       = new HistoryId();
            var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject);

            Assert.DoesNotThrow(() => timeline.DeleteFromTimeline());
        }
Exemple #6
0
        public void DeleteFromTimeline()
        {
            var id       = new HistoryId();
            var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject);

            timeline.AddToTimeline();
            var creationTime = new TimeMarker(1);

            timeline.Mark(creationTime);

            Assert.IsTrue(timeline.IsAlive());
            Assert.AreEqual(creationTime, timeline.CreationTime);
            Assert.IsNull(timeline.DeletionTime);
            Assert.IsNotNull(timeline.Object);

            timeline.DeleteFromTimeline();
            var deletionTime = new TimeMarker(2);

            timeline.Mark(deletionTime);

            Assert.IsFalse(timeline.IsAlive());
            Assert.AreEqual(creationTime, timeline.CreationTime);
            Assert.AreEqual(deletionTime, timeline.DeletionTime);
            Assert.IsNull(timeline.Object);
        }
Exemple #7
0
        public void DeleteFromTimelineWhileDeleted()
        {
            var id       = new HistoryId();
            var timeline = new ObjectTimeline <MockHistoryObject>(id, BuildStorageOfType, BuildObject);

            timeline.AddToTimeline();
            var creationTime = new TimeMarker(1);

            timeline.Mark(creationTime);

            timeline.DeleteFromTimeline();
            var deletionTime = new TimeMarker(2);

            timeline.Mark(deletionTime);

            Assert.DoesNotThrow(() => timeline.DeleteFromTimeline());
        }
Exemple #8
0
        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);
        }