Пример #1
0
        public void CustomObjectSaveTest()
        {
            NFileCache target = new NFileCache("CustomObjectSaveTest");

            // Create custom object
            CustomObjB custom = new CustomObjB
            {
                Num = 5,
                Obj = new CustomObjA
                {
                    Name = "test"
                }
            };

            CacheItem item = new CacheItem("foo")
            {
                Value      = custom,
                RegionName = "foobar"
            };

            // Set it
            target.Set(item, new CacheItemPolicy());

            // Now get it back
            CacheItem fromCache = target.GetCacheItem("foo", "foobar");

            // Pulling twice increases code coverage
            fromCache = target.GetCacheItem("foo", "foobar");
            custom    = fromCache.Value as CustomObjB;

            Assert.IsNotNull(custom);
            Assert.IsNotNull(custom.Obj);
            Assert.AreEqual(custom.Num, 5);
            Assert.AreEqual(custom.Obj.Name, "test");
        }
Пример #2
0
        public void CustomObjectSaveTest()
        {
            NFileCache target = new NFileCache("CustomObjectSaveTest");

            // Create custom object
            CustomObjB custom = new CustomObjB
            {
                Num = 5,
                Obj = new CustomObjA
                {
                    Name = "test"
                }
            };

            CacheItem item = new CacheItem("foo")
            {
                Value = custom,
                RegionName = "foobar"
            };

            // Set it
            target.Set(item, new CacheItemPolicy());

            // Now get it back
            CacheItem fromCache = target.GetCacheItem("foo", "foobar");

            // Pulling twice increases code coverage
            fromCache = target.GetCacheItem("foo", "foobar");
            custom = fromCache.Value as CustomObjB;

            Assert.IsNotNull(custom);
            Assert.IsNotNull(custom.Obj);
            Assert.AreEqual(custom.Num, 5);
            Assert.AreEqual(custom.Obj.Name, "test");
        }