public void ExceptionThrownDuringAddResultsInObjectBeingRemovedFromCacheCompletely() { MockBackingStore backingStore = new MockBackingStore(); ICachingInstrumentationProvider instrumentationProvider = new NullCachingInstrumentationProvider(); Cache cache = new Cache(backingStore, instrumentationProvider); try { cache.Add("foo", "bar"); Assert.Fail("Should have thrown exception thrown internally to Cache.Add"); } catch (Exception) { Assert.IsFalse(cache.Contains("foo")); Assert.AreEqual(1, backingStore.removalCount); } }
public void ExceptionThrownDuringAddResultsInObjectBeingRemovedFromCacheCompletely() { TestConfigurationContext context = new TestConfigurationContext(); MockBackingStore backingStore = new MockBackingStore(); CacheCapacityScavengingPolicy scavengingPolicy = new CacheCapacityScavengingPolicy("test", new CachingConfigurationView(context)); Cache cache = new Cache(backingStore, scavengingPolicy); cache.Initialize(this); try { cache.Add("foo", "bar"); Assert.Fail("Should have thrown exception thrown internally to Cache.Add"); } catch (Exception) { Assert.IsFalse(cache.Contains("foo")); Assert.AreEqual(1, backingStore.removalCount); } }