예제 #1
0
        public void Get_NullReturnedWhenItemDoesNotExist()
        {
            LruStrategy <CacheItem> strategy = new LruStrategy <CacheItem>(2);
            CacheItem item1 = strategy.Get("1");

            Assert.Null(item1);
        }
예제 #2
0
        public void Put_RemovesOldestElement()
        {
            LruStrategy <CacheItem> strategy = new LruStrategy <CacheItem>(2);

            strategy.Put("1", new CacheItem("1", TimeSpan.FromSeconds(10)));
            strategy.Put("2", new CacheItem("2", TimeSpan.FromSeconds(10)));
            strategy.Put("3", new CacheItem("3", TimeSpan.FromSeconds(10)));

            // 1 should be gone
            CacheItem item1 = strategy.Get("1");
            CacheItem item2 = strategy.Get("2");
            CacheItem item3 = strategy.Get("3");

            Assert.Null(item1);
            Assert.NotNull(item2);
            Assert.NotNull(item3);
        }
예제 #3
0
        public void Get_ItemReturned()
        {
            LruStrategy <CacheItem> strategy = new LruStrategy <CacheItem>(2);

            strategy.Put("1", new CacheItem("1", TimeSpan.FromSeconds(10)));

            CacheItem item1 = strategy.Get("1");

            Assert.NotNull(item1);
        }