public void LRUChainItemTests_Constructor()
        {
            string str       = "hello";
            var    chainItem = new LRUChainItem <string>(value: str);

            Assert.AreEqual(str, chainItem.ItemValue);
        }
Beispiel #2
0
        public void LRUChainTests_GetItemToEvict_on_list_with_one_item()
        {
            var item_1 = new LRUChainItem <string>("foo");

            _chain.AddFirst(item_1);

            Assert.AreEqual(item_1, _chain.GetItemToEvict());
        }
Beispiel #3
0
        public void LRUChainTests_AddFirst_only_one_item()
        {
            var item_1 = new LRUChainItem <string>("foo");

            _chain.AddFirst(item_1);

            Assert.AreEqual(item_1, _chain.TestEnabler_GetHead());
            Assert.AreEqual(item_1, _chain.TestEnabler_GetTail());
        }
Beispiel #4
0
        public void LRUChainTests_AddFirst_two_items()
        {
            var item_1 = new LRUChainItem <string>("foo");
            var item_2 = new LRUChainItem <string>("bar");

            _chain.AddFirst(item_1);
            _chain.AddFirst(item_2);

            Assert.AreEqual(item_2, _chain.TestEnabler_GetHead());
            Assert.AreEqual(item_1, _chain.TestEnabler_GetTail());
        }
Beispiel #5
0
        public void LRUChainTests_Remove_when_only_one_item()
        {
            var item_1 = new LRUChainItem <string>("foo");

            _chain.AddFirst(item_1);

            _chain.Remove(item_1);

            Assert.IsNull(_chain.TestEnabler_GetHead());
            Assert.IsNull(_chain.TestEnabler_GetTail());
        }
Beispiel #6
0
        public void LRUChainTests_GetItemToEvict_on_list_with_three_items()
        {
            var item_1 = new LRUChainItem <string>("foo");
            var item_2 = new LRUChainItem <string>("bar");
            var item_3 = new LRUChainItem <string>("who");

            _chain.AddFirst(item_1);
            _chain.AddFirst(item_2);
            _chain.AddFirst(item_3);

            Assert.AreEqual(item_1, _chain.GetItemToEvict());
        }
Beispiel #7
0
        public void LRUChainTests_Remove_tail_when_two_items()
        {
            var item_1 = new LRUChainItem <string>("foo");
            var item_2 = new LRUChainItem <string>("bar");

            _chain.AddFirst(item_1);
            _chain.AddFirst(item_2);

            // item_2 is the head
            _chain.Remove(item_1);

            Assert.AreEqual(item_2, _chain.TestEnabler_GetHead());
            Assert.AreEqual(item_2, _chain.TestEnabler_GetTail());
        }
Beispiel #8
0
        public void LRUChainTests_Promote_with_three_items_promote_middle_item()
        {
            var item_1 = new LRUChainItem <string>("foo");
            var item_2 = new LRUChainItem <string>("bar");
            var item_3 = new LRUChainItem <string>("who");

            _chain.AddFirst(item_1);
            _chain.AddFirst(item_2);
            _chain.AddFirst(item_3);

            _chain.Promote(item_2);

            Assert.AreEqual(item_2, _chain.TestEnabler_GetHead());
            Assert.AreEqual(item_1, _chain.TestEnabler_GetTail());
        }
Beispiel #9
0
        public void LRUChainTests_Remove_tail_when_three_items()
        {
            var item_1 = new LRUChainItem <string>("foo");
            var item_2 = new LRUChainItem <string>("bar");
            var item_3 = new LRUChainItem <string>("who");

            _chain.AddFirst(item_1);
            _chain.AddFirst(item_2);
            _chain.AddFirst(item_3);

            // order is 3, 2, 1
            _chain.Remove(item_1);

            Assert.AreEqual(item_3, _chain.TestEnabler_GetHead());
            Assert.AreEqual(item_2, _chain.TestEnabler_GetTail());
        }