public void MemoizationCacheBase_Simple()
        {
            var cleared   = false;
            var disposing = false;

            var c = new MyCache
            {
                CountF        = () => 42,
                DebugViewF    = () => "foo",
                ClearA        = b => { Assert.AreEqual(disposing, b); cleared = true; },
                GetOrAddCoreF = x => x + 1,
            };

            Assert.AreEqual(42, c.Count);
            Assert.AreEqual("foo", c.DebugView);
            Assert.AreEqual(2, c.GetOrAdd(1));

            cleared   = false;
            disposing = false;
            c.Clear();
            Assert.IsTrue(cleared);

            cleared   = false;
            disposing = true;
            c.Dispose();
            Assert.IsTrue(cleared);

            Assert.AreEqual(0, c.Count);
            Assert.AreNotEqual("foo", c.DebugView);

            Assert.ThrowsException <ObjectDisposedException>(() => c.GetOrAdd(2));
        }
Beispiel #2
0
 /// <summary>
 /// remove all elements from cache - needed for full Refresh
 /// </summary>
 public static void Clear()
 {
     m_featuresCache.Clear();
     m_backdropCache.Clear();
 }
Beispiel #3
0
 /// <summary>
 /// remove all elements from cache - needed for full Refresh
 /// </summary>
 public static void Clear()
 {
     m_backdropCache.Clear();
 }