コード例 #1
0
ファイル: CacheTests.cs プロジェクト: nevergofull/A
        public void Dictionary_ReplaceWithoutPrevious_1()
        {
            //we used to add this to cache if it didn't exist, now we don't
            string cacheKey = "Dictionary_Add";

            handler.Remove(cacheKey);

            var newItem = new Item()
            {
                ID = 1, Count = 400, Name = "New Name"
            };

            handler.DictionaryReplace <int, Item>(cacheKey, 1, newItem);
            Assert.IsFalse(handler.DictionaryExists(cacheKey, 1));

            var newItem2 = new Item()
            {
                ID = 2, Count = 400, Name = "New Name"
            };

            handler.DictionaryReplace(cacheKey, 2, newItem2);
            Assert.IsFalse(handler.DictionaryExists(cacheKey, 2));

            var cacheItem = handler.DictionaryRetrieve <int, Item>(cacheKey, 1);

            Assert.IsNull(cacheItem);
            //Assert.AreEqual(newItem.ID, cacheItem.ID);
            //Assert.AreEqual(newItem.Count, cacheItem.Count);
            //Assert.AreEqual(newItem.Name, cacheItem.Name);

            handler.Remove(cacheKey);
        }