public void RollBackToStartWithNoValues()
        {
            var objects = new Dictionary <HistoryId, MockHistoryObject>();
            Func <HistoryId, MockHistoryObject> lookupFunc =
                id => objects[id];
            var storage = new HistoryObjectValueHistory <MockHistoryObject>(lookupFunc);

            Assert.DoesNotThrow(() => storage.RollBackToStart());
        }
        public void RollBackToFirstValue()
        {
            var objects = new Dictionary <HistoryId, MockHistoryObject>();
            Func <HistoryId, MockHistoryObject> lookupFunc =
                id => objects[id];
            var storage = new HistoryObjectValueHistory <MockHistoryObject>(lookupFunc);

            int maximumValue = 10;

            for (int i = 0; i < maximumValue; i++)
            {
                var obj = new MockHistoryObject(i);
                objects.Add(obj.HistoryId, obj);
                storage.Current = obj;
                storage.StoreCurrent(new TimeMarker((ulong)(i + 1)));
            }

            storage.RollBackTo(new TimeMarker(1));
            MockHistoryObject storedValue = storage;

            Assert.AreSame(objects[new HistoryId(0)], storedValue);
        }
        public void RollBackToStart()
        {
            var objects = new Dictionary <HistoryId, MockHistoryObject>();
            Func <HistoryId, MockHistoryObject> lookupFunc =
                id => (id != null) ? objects[id] : null;
            var storage = new HistoryObjectValueHistory <MockHistoryObject>(lookupFunc);

            int maximumValue = 10;

            for (int i = 0; i < maximumValue; i++)
            {
                var obj = new MockHistoryObject(i);
                objects.Add(obj.HistoryId, obj);
                storage.Current = obj;
                storage.StoreCurrent(new TimeMarker((ulong)(i + 1)));
            }

            storage.RollBackToStart();
            MockHistoryObject storedValue = storage;

            Assert.AreEqual(null, storedValue);
        }
Exemple #4
0
 public static T FromStorage(HistoryObjectValueHistory <T> storage)
 {
     return((storage != null) ? storage.Current : null);
 }