Esempio n. 1
0
        public void RollForwardWithLocalChange()
        {
            var storage = new ListHistory <int>();

            int maximumValue = 10;

            for (int i = 1; i < maximumValue; i++)
            {
                storage.Add(i);
                storage.StoreCurrent(new TimeMarker((ulong)i));
            }

            storage.RollBackToStart();
            storage.Add(maximumValue + 1);

            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(j));
                }
            }
        }
Esempio n. 2
0
        public void RemoveItems()
        {
            var list = new ListHistory <string>
            {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
            };

            list.Remove("a");
            Assert.IsFalse(list.Contains("a"));

            list.Remove("b");
            Assert.IsFalse(list.Contains("b"));

            list.Remove("c");
            Assert.IsFalse(list.Contains("c"));

            list.Remove("d");
            Assert.IsFalse(list.Contains("d"));

            list.Remove("e");
            Assert.IsFalse(list.Contains("e"));

            list.Remove("f");
            Assert.IsFalse(list.Contains("f"));
        }
Esempio n. 3
0
        public void RollBackMultipleTimes()
        {
            var storage = new ListHistory <int>();

            int maximumValue = 10;

            for (int i = 0; i < maximumValue; i++)
            {
                storage.Add(i);
                storage.StoreCurrent(new TimeMarker((ulong)(i + 1)));
            }

            for (int i = maximumValue; i > 0; i--)
            {
                storage.RollBackTo(new TimeMarker((ulong)i));
                Assert.AreEqual(i, storage.Count);
                for (int j = 1; j <= i; j++)
                {
                    Assert.IsTrue(storage.Contains(j - 1));
                }
            }
        }