public void Item_should_be_removed_on_demand() { ICache cache = new LruCache(); cache[0] = 0; Assert.That(cache[0], Is.Not.Null); cache.Remove(0); Assert.That(cache[0], Is.Null); }
public void Cache_should_be_clear_on_demand() { ICache cache = new LruCache(); for (int i = 0; i < 5; i++) { cache[i] = i; } Assert.That(cache[0], Is.Not.Null); Assert.That(cache[4], Is.Not.Null); cache.Clear(); Assert.That(cache[0], Is.Null); Assert.That(cache[4], Is.Null); }
public void Least_recently_used_item_should_be_removed() { LruCache cache = new LruCache(); cache.Size = 5; for (int i = 0; i < 5; i++) { cache[i] = i; } Assert.That(cache[0], Is.EqualTo(0)); cache[5] = 5; Assert.That(cache[1], Is.Null); Assert.That(cache.Size, Is.EqualTo(5)); }