コード例 #1
0
ファイル: TestStress.cs プロジェクト: tm011064/Luputa
        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);
                }
            }
        }
コード例 #2
0
ファイル: TestStress.cs プロジェクト: tm011064/Luputa
        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);
                }
            }
        }
コード例 #3
0
ファイル: TestStress.cs プロジェクト: tm011064/Luputa
        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()));
                }
            }
        }
コード例 #4
0
ファイル: TestStress.cs プロジェクト: tm011064/Luputa
        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()));
                }
            }
        }