예제 #1
0
        public void RemoveCachedItem()
        {
            var cache = new FileLruCache <Item>(2, x => new Item(x));
            var arg   = Path.GetTempFileName();

            var result1 = cache.Get(arg);
            var removed = cache.Remove(arg);
            var result2 = cache.Get(arg);

            Assert.True(removed);
            Assert.NotSame(result1, result2);
            Assert.Equal(arg, result1.Path);
            Assert.Equal(arg, result2.Path);
        }
예제 #2
0
        public void RemoveUncachedItem()
        {
            var cache = new FileLruCache <Item>(2, x => new Item(x));
            var arg1  = Path.GetTempFileName();
            var arg2  = Path.GetTempFileName();

            var result1 = cache.Get(arg1);
            var removed = cache.Remove(arg2);
            var result2 = cache.Get(arg1);

            Assert.False(removed);
            Assert.Same(result1, result2);
            Assert.Equal(arg1, result1.Path);
            Assert.Equal(arg1, result2.Path);
        }