public void StoreMinimalCacheItemIntoIsolatedStorage()
        {
            CacheItem itemToStore = new CacheItem("key", "value", CacheItemPriority.NotRemovable, null);

            string itemRoot = DirectoryRoot + itemToStore.Key;
            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, null);
            item.Store(itemToStore);

            Assert.AreEqual(1, storage.GetDirectoryNames(DirectoryRoot + @"\*").Length);
        }
Esempio n. 2
0
        public void StoreMinimalCacheItemIntoIsolatedStorage()
        {
            CacheItem itemToStore = new CacheItem("key", "value", CacheItemPriority.NotRemovable, null);

            string itemRoot = DirectoryRoot + itemToStore.Key;
            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, null);

            item.Store(itemToStore);

            Assert.AreEqual(1, storage.GetDirectoryNames(DirectoryRoot + @"\*").Length);
        }
Esempio n. 3
0
        public void StoreAndEncryptItem()
        {
            IStorageEncryptionProvider encryptionProvider = new MockStorageEncryptionProvider();

            CacheItem itemToStore = new CacheItem("key", "value", CacheItemPriority.NotRemovable, null);

            string itemRoot = DirectoryRoot + itemToStore.Key;
            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);

            item.Store(itemToStore);

            Assert.AreEqual(1, storage.GetDirectoryNames(DirectoryRoot + @"\*").Length);
        }
        private CacheItem DoCacheItemRoundTripToStorage(CacheItem itemToStore, bool encrypted)
        {
            IStorageEncryptionProvider encryptionProvider = null;

            if (encrypted)
            {
                encryptionProvider = new MockStorageEncryptionProvider();
            }

            string itemRoot = DirectoryRoot + itemToStore.Key;

            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);

            item.Store(itemToStore);

            IsolatedStorageCacheItem itemToRead = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);

            return(itemToRead.Load());
        }
Esempio n. 5
0
        public void UpdateLastAccessedTime()
        {
            CacheItem historicalItem = new CacheItem("foo", "bar", CacheItemPriority.NotRemovable, null);

            historicalItem.SetLastAccessedTime(DateTime.Now - TimeSpan.FromHours(1.0));

            string itemRoot = DirectoryRoot + historicalItem.Key;
            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, null);

            item.Store(historicalItem);

            DateTime now = DateTime.Now;

            historicalItem.SetLastAccessedTime(DateTime.Now);
            item.UpdateLastAccessedTime(now);

            CacheItem restoredItem = item.Load();

            Assert.AreEqual(restoredItem.LastAccessedTime, now);
        }
        CacheItem DoCacheItemRoundTripToStorage(CacheItem itemToStore,
                                                bool encrypted)
        {
            IStorageEncryptionProvider encryptionProvider = null;

            if (encrypted)
            {
                encryptionProvider = new MockStorageEncryptionProvider();
            }

            string itemRoot = DirectoryRoot + itemToStore.Key;

            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);
            item.Store(itemToStore);

            IsolatedStorageCacheItem itemToRead = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);
            return itemToRead.Load();
        }
        public void StoreAndEncryptItem()
        {
            IStorageEncryptionProvider encryptionProvider = new MockStorageEncryptionProvider();

            CacheItem itemToStore = new CacheItem("key", "value", CacheItemPriority.NotRemovable, null);

            string itemRoot = DirectoryRoot + itemToStore.Key;
            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);
            item.Store(itemToStore);

            Assert.AreEqual(1, storage.GetDirectoryNames(DirectoryRoot + @"\*").Length);
        }
        public void UpdateLastAccessedTime()
        {
            CacheItem historicalItem = new CacheItem("foo", "bar", CacheItemPriority.NotRemovable, null);
            historicalItem.SetLastAccessedTime(DateTime.Now - TimeSpan.FromHours(1.0));

            string itemRoot = DirectoryRoot + historicalItem.Key;
            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, null);
            item.Store(historicalItem);

            DateTime now = DateTime.Now;
            historicalItem.SetLastAccessedTime(DateTime.Now);
            item.UpdateLastAccessedTime(now);

            CacheItem restoredItem = item.Load();

            Assert.AreEqual(restoredItem.LastAccessedTime, now);
        }
        private CacheItem DoCacheItemRoundTripToStorage(CacheItem itemToStore, bool encrypted)
        {
            IStorageEncryptionProvider encryptionProvider = null;

            if (encrypted)
            {
                encryptionProvider = new MockStorageEncryptionProvider();
                encryptionProvider.Initialize(new CachingConfigurationView(Context));
            }

            string itemRoot = DirectoryRoot + itemToStore.Key;

            IsolatedStorageCacheItem item = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);
            item.Store(itemToStore);

            IsolatedStorageCacheItem itemToRead = new IsolatedStorageCacheItem(storage, itemRoot, encryptionProvider);
            return itemToRead.Load();
        }