public void Item_should_be_removed_on_demand() { ICache cache = new WeakCache(); cache[0] = 0; Assert.That(cache[0], Is.Not.Null); cache.Remove(0); Assert.That(cache[0], Is.Null); }
public void Demonstrate_that_copies_are_equals() { ICache cache = new WeakCache(); cache = new SharedCache(cache); for (int i = 0; i < 100000; i++) { cache[i] = i; object value = cache[i]; Assert.That(value, Is.Null | Is.EqualTo(i)); } }
public void Least_recently_used_item_should_be_removed() { WeakCache cache = new WeakCache(); for (int i = 0; i < 1000000; i++) { cache[i] = i; } GC.Collect(); object o = cache[0]; Assert.That(cache.Size, Is.EqualTo(999999)); }
public void Cache_should_be_clear_on_demand() { ICache cache = new WeakCache(); 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); }