Beispiel #1
0
        public void Test_LoopThroughExpiredCachedListWithLocalCopyAndNullCheck()
        {
            int numberOfItems = 10;

            Dictionary <int, string> records = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems);

            string value;
            int    half = numberOfItems / 2;


            SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
            records = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems);
            Trace.WriteLine("\n\nStart Loop through local copy");
            foreach (int key in records.Keys)
            {
                if (half == key)
                {
                    Trace.WriteLine("Remove object from cache");
                    SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
                    Assert.AreEqual(false, SlimCacheManager.IsObjectCached(TestCacheItem.slim_testitem_1.ToString()));

                    Trace.WriteLine("Insert object into cache with half amount of items");
                    records = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, half);
                    DebugUtility.GetDebugString(records);
                }

                if (records.ContainsKey(key))
                {
                    value = records[key];
                    Trace.WriteLine("Successfully retrieved value: " + value);
                }
            }
        }
Beispiel #2
0
        public void Test_LoopThroughExpiredCachedListWithReinsertedValues()
        {
            int    numberOfItems = 10;
            string value;
            int    half = numberOfItems / 2;

            SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
            Trace.WriteLine("\n\nStart Loop through direct access with change");
            foreach (int key in GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems).Keys)
            {
                if (half == key)
                {
                    Trace.WriteLine("Remove object from cache");
                    SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
                    Assert.AreEqual(false, SlimCacheManager.IsObjectCached(TestCacheItem.slim_testitem_1.ToString()));

                    Trace.WriteLine("Insert object into cache with half amount of items");
                    var records = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, half);
                    DebugUtility.GetDebugString(records);
                }

                if (key >= half)
                {
                    Assert.Throws <KeyNotFoundException>(delegate { value = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems)[key]; });
                }
                else
                {
                    value = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems)[key];
                    Trace.WriteLine("Successfully retrieved value: " + value);
                }
            }
        }
Beispiel #3
0
        public void Test_LoopThroughExpiredCachedList()
        {
            int    numberOfItems = 10;
            string value;
            int    half = numberOfItems / 2;

            SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
            Trace.WriteLine("\n\nStart Loop through direct access");
            foreach (int key in GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems).Keys)
            {
                value = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems)[key];
                Trace.WriteLine("Successfully retrieved value: " + value);

                if (half == key)
                {
                    Trace.WriteLine("Remove object from cache");
                    SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
                    Assert.AreEqual(false, SlimCacheManager.IsObjectCached(TestCacheItem.slim_testitem_1.ToString()));
                }
            }
        }
Beispiel #4
0
        public void Test_LoopThroughExpiredCachedListWithLocalCopy()
        {
            int numberOfItems = 10;

            Dictionary <int, string> records = GetDictionaryFromCache(TestCacheItem.slim_testitem_1, numberOfItems);

            string value;
            int    half = numberOfItems / 2;

            Trace.WriteLine("Start Loop through local copy");
            foreach (int key in records.Keys)
            {
                value = records[key];
                Trace.WriteLine("Successfully retrieved value: " + value);

                if (half == key)
                {
                    Trace.WriteLine("Remove object from cache");
                    SlimCacheManager.PurgeCacheItem(TestCacheItem.slim_testitem_1.ToString());
                    Assert.AreEqual(false, SlimCacheManager.IsObjectCached(TestCacheItem.slim_testitem_1.ToString()));
                }
            }
        }