本文整理匯總了C#中MonoTests.Common.PokerMemoryCache.Remove方法的典型用法代碼示例。如果您正苦於以下問題:C# PokerMemoryCache.Remove方法的具體用法?C# PokerMemoryCache.Remove怎麽用?C# PokerMemoryCache.Remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoTests.Common.PokerMemoryCache
的用法示例。
在下文中一共展示了PokerMemoryCache.Remove方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Remove
public void Remove ()
{
var mc = new PokerMemoryCache ("MyCache");
AssertExtensions.Throws<NotSupportedException> (() => {
mc.Remove ("key", "region");
}, "#A1-1");
AssertExtensions.Throws<ArgumentNullException> (() => {
mc.Remove (null);
}, "#A1-2");
bool callbackInvoked;
CacheEntryRemovedReason reason = (CacheEntryRemovedReason) 1000;
var cip = new CacheItemPolicy ();
cip.Priority = CacheItemPriority.NotRemovable;
mc.Set ("key2", "value1", cip);
object value = mc.Remove ("key2");
Assert.IsNotNull (value, "#B1-1");
Assert.IsFalse (mc.Contains ("key2"), "#B1-2");
cip = new CacheItemPolicy ();
cip.RemovedCallback = (CacheEntryRemovedArguments args) => {
callbackInvoked = true;
reason = args.RemovedReason;
};
mc.Set ("key", "value", cip);
callbackInvoked = false;
reason = (CacheEntryRemovedReason) 1000;
value = mc.Remove ("key");
Assert.IsNotNull (value, "#C1-1");
Assert.IsTrue (callbackInvoked, "#C1-2");
Assert.AreEqual (CacheEntryRemovedReason.Removed, reason, "#C1-3");
cip = new CacheItemPolicy ();
cip.RemovedCallback = (CacheEntryRemovedArguments args) => {
callbackInvoked = true;
reason = args.RemovedReason;
throw new ApplicationException ("test");
};
mc.Set ("key", "value", cip);
callbackInvoked = false;
reason = (CacheEntryRemovedReason) 1000;
value = mc.Remove ("key");
Assert.IsNotNull (value, "#C2-1");
Assert.IsTrue (callbackInvoked, "#C2-2");
Assert.AreEqual (CacheEntryRemovedReason.Removed, reason, "#C2-3");
// LAMESPEC: UpdateCallback is not called on remove
cip = new CacheItemPolicy ();
cip.UpdateCallback = (CacheEntryUpdateArguments args) => {
callbackInvoked = true;
reason = args.RemovedReason;
};
mc.Set ("key", "value", cip);
callbackInvoked = false;
reason = (CacheEntryRemovedReason) 1000;
value = mc.Remove ("key");
Assert.IsNotNull (value, "#D1-1");
Assert.IsFalse (callbackInvoked, "#D1-2");
cip = new CacheItemPolicy ();
cip.UpdateCallback = (CacheEntryUpdateArguments args) => {
callbackInvoked = true;
reason = args.RemovedReason;
throw new ApplicationException ("test");
};
mc.Set ("key", "value", cip);
callbackInvoked = false;
reason = (CacheEntryRemovedReason) 1000;
value = mc.Remove ("key");
Assert.IsNotNull (value, "#D2-1");
Assert.IsFalse (callbackInvoked, "#D2-2");
}