public void RemoveItemsAtInvalidIndex()
        {
            var list = new HistoryObjectListHistory <MockHistoryObject>(FromId)
            {
                new MockHistoryObject(0),
                new MockHistoryObject(1),
                new MockHistoryObject(2),
                new MockHistoryObject(3),
                new MockHistoryObject(4),
                new MockHistoryObject(5),
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveAt(-1));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count));
        }
        public void RollForwardThroughRemove()
        {
            var objects = new Dictionary <HistoryId, MockHistoryObject>();
            Func <HistoryId, MockHistoryObject> lookupFunc = id => objects[id];
            var storage = new HistoryObjectListHistory <MockHistoryObject>(lookupFunc);

            int maximumValue = 10;

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

            storage.StoreCurrent(new TimeMarker(1));

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

            storage.RollBackToStart();
            storage.RollForwardTo(new TimeMarker(2));
            Assert.AreEqual(maximumValue - 1, storage.Count);
            for (int i = 0; i < storage.Count; i++)
            {
                if (i < 5)
                {
                    Assert.AreSame(objects[new HistoryId(i)], storage[i]);
                }
                else
                {
                    Assert.AreSame(objects[new HistoryId(i + 1)], storage[i]);
                }
            }
        }
        public void RemoveItemsAt()
        {
            var list = new HistoryObjectListHistory <MockHistoryObject>(FromId)
            {
                new MockHistoryObject(0),
                new MockHistoryObject(1),
                new MockHistoryObject(2),
                new MockHistoryObject(3),
                new MockHistoryObject(4),
                new MockHistoryObject(5),
            };

            list.RemoveAt(3);
            Assert.IsFalse(list.Contains(new MockHistoryObject(3)));

            list.RemoveAt(3);
            Assert.IsFalse(list.Contains(new MockHistoryObject(4)));

            list.RemoveAt(3);
            Assert.IsFalse(list.Contains(new MockHistoryObject(5)));

            list.RemoveAt(2);
            Assert.IsFalse(list.Contains(new MockHistoryObject(2)));

            list.RemoveAt(1);
            Assert.IsFalse(list.Contains(new MockHistoryObject(1)));

            list.RemoveAt(0);
            Assert.IsFalse(list.Contains(new MockHistoryObject(0)));
        }