public void RollBackThroughRemove()
        {
            var storage = new DictionaryHistory <int, int>();

            int maximumValue = 10;

            for (int i = 0; i < maximumValue; i++)
            {
                storage.Add(i, i);
            }

            storage.StoreCurrent(new TimeMarker(1));

            storage.Remove(5);
            storage.StoreCurrent(new TimeMarker(2));

            storage.RollBackTo(new TimeMarker(1));
            Assert.AreEqual(maximumValue, storage.Count);

            int index = 0;

            foreach (var pair in storage)
            {
                Assert.AreEqual(index, pair.Key);
                Assert.AreEqual(index, pair.Value);

                index++;
            }
        }
        public void RemoveWithUnknownKey()
        {
            var storage = new DictionaryHistory <int, int>();

            int key   = 5;
            int value = 10;

            storage.Add(key, value);

            Assert.IsFalse(storage.Remove(value));
        }
        public void RemoveWithNullKey()
        {
            var storage = new DictionaryHistory <string, string>();

            bool result = true;

            Assert.DoesNotThrow(
                () =>
            {
                result = storage.Remove(null);
            });
            Assert.IsFalse(result);
        }
        public void Remove()
        {
            var storage = new DictionaryHistory <int, int>();

            int key   = 5;
            int value = 10;

            storage.Add(key, value);

            var result = storage.Remove(key);

            Assert.IsTrue(result);
            Assert.AreEqual(0, storage.Count);
            Assert.IsFalse(storage.ContainsKey(key));
        }
        public void RemoveVoidsForwardStack()
        {
            var storage = new DictionaryHistory <int, int>();

            int maximumValue = 10;

            for (int i = 0; i < maximumValue; i++)
            {
                storage.Add(i, i);
            }

            storage.StoreCurrent(new TimeMarker(1));
            storage[5] = maximumValue;
            storage.StoreCurrent(new TimeMarker(2));

            storage.RollBackTo(new TimeMarker(1));

            storage.Remove(5);
            storage.StoreCurrent(new TimeMarker(3));

            storage.RollForwardTo(new TimeMarker(2));
            Assert.AreEqual(maximumValue - 1, storage.Count);

            int index = 0;

            foreach (var pair in storage)
            {
                if (index < 5)
                {
                    Assert.AreEqual(index, pair.Key);
                    Assert.AreEqual(index, pair.Value);
                }
                else
                {
                    Assert.AreEqual(index + 1, pair.Key);
                    Assert.AreEqual(index + 1, pair.Value);
                }

                index++;
            }
        }