Beispiel #1
0
        public ILRUCache <SimpleLRUCacheItem, int> MakeRainbowCache_lockfree(int Capacity)
        {
            var c = new LRUCache_lockfree <SimpleLRUCacheItem, int, string>(Capacity);

            SimpleLRUCacheTests_lockfree.AddRainbowItems(c);
            return(c);
        }
Beispiel #2
0
        public void TestMaxSize_Cleanup()
        {
            var c = MakeRainbowCache_lockfree(4);

            SimpleLRUCacheTests_lockfree.DumpCache(c, "After Creation");
            Assert.AreEqual(4, c.Count, 0, "Cache size is not 4");
            Console.WriteLine("Test Complete.");
        }
Beispiel #3
0
 public void TestFind(ILRUCache <SimpleLRUCacheItem, int> c)
 {
     Assert.AreEqual(7, c.Count, 0, "Cache size is not 7");
     Assert.AreEqual("Red", c.Get(0).Value, "Cache did not contain key 0");
     Assert.AreEqual("Violet", c.Get(6).Value, "Cache did not contain key 6");
     SimpleLRUCacheTests_lockfree.DumpCache(c, "Most Used/ Recently added to Least used/Oldest ");
     Console.WriteLine("Test Complete.");
 }
Beispiel #4
0
        public void CreateLRUCache_lockfree()
        {
            ILRUCache <SimpleLRUCacheItem, int> c = new LRUCache_lockfree <SimpleLRUCacheItem, int, string>();

            Console.WriteLine("Created Empty Cache.");
            Assert.AreEqual(0, c.Count, 0, "Cache size is not zero");
            c.Put(new SimpleLRUCacheItem(1, "Red"));
            Assert.AreEqual(1, c.Count, 0, "Cache size is not one");
            c.Put(new SimpleLRUCacheItem(2, "Blue"));
            Assert.AreEqual(2, c.Count, 0, "Cache size is not two");
            SimpleLRUCacheTests_lockfree.DumpCache(c, "Most Used/ Recently added to Least used/Oldest ");
            Console.WriteLine("lockfree Test Complete.");
        }
Beispiel #5
0
        public void TestMaxSize_Find()
        {
            var c = MakeRainbowCache_lockfree(4);

            SimpleLRUCacheTests_lockfree.DumpCache(c, "After Creation");
            try
            {
                var val = c.Get(0);
                //Assert.AreEqual(4, c.Count, 0, "Cache size is not 4");
            }
            catch
            {
                // Ignore
            }
            finally
            {
                SimpleLRUCacheTests_lockfree.DumpCache(c, "\nAfter Find");
                Console.WriteLine("Test Complete.");
            }
        }