public void EvictionOrder()
        {
            var schema = TypedSchemaFactory.FromType(typeof(TradeLike));

            var queue = new EvictionQueue {
                Capacity = 9, EvictionCount = 2
            };

            var allItems = new List <PackedObject>();

            for (var i = 0; i < 10; i++)
            {
                var item       = new TradeLike(i, 1000 + i, "aaa", DateTime.Now, 456);
                var packedItem = PackedObject.Pack(item, schema);
                queue.AddNew(packedItem);
                allItems.Add(packedItem);
            }

            //items in queue now: 0 1 2 3 4 5 6 7 8 9

            Assert.IsTrue(queue.EvictionRequired);
            var evicted = queue.Go();

            //items in queue: 3 4 5 6 7 8 9

            Assert.AreEqual(evicted.Count, 3);

            Assert.AreEqual(evicted[0].PrimaryKey, 0);
            Assert.AreEqual(evicted[1].PrimaryKey, 1);

            queue.Touch(allItems[3]);
            //items in queue: 4 5 6 7 8 9 3

            queue.Touch(allItems[4]);
            //items in queue: 5 6 7 8 9 3 4

            queue.Capacity = 7;
            evicted        = queue.Go();

            Assert.AreEqual(evicted.Count, 2);

            Assert.AreEqual(evicted[0].PrimaryKey, 5);
            Assert.AreEqual(evicted[1].PrimaryKey, 6);
        }
        public void EvictionOrder()
        {
            EvictionQueue queue = new EvictionQueue();

            queue.Capacity      = 9;
            queue.EvictionCount = 2;

            List <CachedObject> allItems = new List <CachedObject>();

            for (int i = 0; i < 10; i++)
            {
                TradeLike    item       = new TradeLike(i, 1000 + i, "aaa", DateTime.Now, 456);
                CachedObject packedItem = CachedObject.Pack(item);
                queue.AddNew(packedItem);
                allItems.Add(packedItem);
            }

            //items in queue now: 0 1 2 3 4 5 6 7 8 9

            Assert.IsTrue(queue.EvictionRequired);
            IList <CachedObject> evicted = queue.GO();

            //items in queue: 3 4 5 6 7 8 9

            Assert.AreEqual(evicted.Count, 3);

            Assert.AreEqual(evicted[0].PrimaryKey, 0);
            Assert.AreEqual(evicted[1].PrimaryKey, 1);

            queue.Touch(allItems[3]);
            //items in queue: 4 5 6 7 8 9 3

            queue.Touch(allItems[4]);
            //items in queue: 5 6 7 8 9 3 4

            queue.Capacity = 7;
            evicted        = queue.GO();

            Assert.AreEqual(evicted.Count, 2);

            Assert.AreEqual(evicted[0].PrimaryKey, 5);
            Assert.AreEqual(evicted[1].PrimaryKey, 6);
        }