public void MruOverCapacity() { var cache = CacheBuilder.MRU_ThreadSafe <int, int>(3); cache[1] = 10; cache[2] = 20; cache[3] = 30; Assert.IsTrue(cache.ContainsKey(3)); cache[4] = 40; Assert.IsFalse(cache.ContainsKey(3)); }
public void MruAccess() //New 1.01: missed test coverage { var cache = CacheBuilder.MRU_ThreadSafe <int, int>(3); cache[1] = 10; cache[2] = 20; cache[3] = 30; var v1 = cache[1]; var v2 = cache[2]; Assert.IsTrue(cache.ContainsKey(2)); cache[4] = 40; Assert.IsFalse(cache.ContainsKey(2)); }
public void MruRollingPuts() { const int capacity = 3; var cache = CacheBuilder.MRU_ThreadSafe <int, int>(capacity); cache[1] = 10; cache[2] = 20; cache[3] = 30; for (int i = 4; i < 100; i++) { Assert.IsTrue(cache.ContainsKey(i - 1)); cache[i] = 10 * i; Assert.IsFalse(cache.ContainsKey(i - 1)); } }
public void Remove() //New 1.01 { var cache = CacheBuilder.MRU_ThreadSafe <int, int>(3); cache[1] = 10; cache[2] = 20; cache[3] = 30; var v1 = cache[1]; var v2 = cache[2]; cache.Remove(1); Assert.IsFalse(cache.ContainsKey(1)); cache[4] = 40; Assert.IsTrue(cache.ContainsKey(2)); }
private ICache <int, int> GetCache(CacheType cacheType, int capacity) { switch (cacheType) { case CacheType.LRU_ThreadSafe: return(CacheBuilder.LRU_ThreadSafe <int, int>(capacity)); case CacheType.LRU_Non_ThreadSafe: return(CacheBuilder.LRU_NonThreadSafe <int, int>(capacity)); case CacheType.MRU_ThreadSafe: return(CacheBuilder.MRU_ThreadSafe <int, int>(capacity)); case CacheType.MRU_Non_ThreadSafe: return(CacheBuilder.MRU_NonThreadSafe <int, int>(capacity)); default: throw new NotSupportedException(cacheType.ToString()); } }