public void If_Removes_Throws_Cache_Is_Removed() { var cacheCleared = false; var cache = new Mock <IRuntimeCacheProvider>(); cache.Setup(x => x.ClearCacheItem(It.IsAny <string>())) .Callback(() => { cacheCleared = true; }); var defaultPolicy = new DefaultRepositoryCachePolicy <AuditItem, object>(cache.Object, new RepositoryCachePolicyOptions()); try { defaultPolicy.Delete(new AuditItem(1, "blah", AuditType.Copy, 123), item => { throw new Exception("blah!"); }); } catch { //we need this catch or nunit throw up } finally { Assert.IsTrue(cacheCleared); } }
public void If_Removes_Throws_Cache_Is_Removed() { var cacheCleared = false; var cache = new Mock <IAppPolicyCache>(); cache.Setup(x => x.Clear(It.IsAny <string>())) .Callback(() => cacheCleared = true); var defaultPolicy = new DefaultRepositoryCachePolicy <AuditItem, object>(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions()); try { defaultPolicy.Delete(new AuditItem(1, AuditType.Copy, 123, "test", "blah"), item => throw new Exception("blah!")); } catch { // We need this catch or nunit throws up } finally { Assert.IsTrue(cacheCleared); } }