public void ItemAddedPreviousToFailedAddIsRemovedCompletelyIfSecondAddFails()
        {            
            using (IsolatedStorageBackingStore backingStore = new IsolatedStorageBackingStore("foo", null))
            {
                CacheCapacityScavengingPolicy scavengingPolicy = new CacheCapacityScavengingPolicy(10);
				CachingInstrumentationProvider instrumentationProvider = new CachingInstrumentationProvider();

                Cache cache = new Cache(backingStore, scavengingPolicy, instrumentationProvider);
                cache.Initialize(this);

                cache.Add("my", new SerializableClass());

                try
                {
                    cache.Add("my", new NonSerializableClass());
                    Assert.Fail("Should have thrown exception internally to Cache.Add");
                }
                catch (Exception)
                {
                    Assert.IsFalse(cache.Contains("my"));
                    Assert.AreEqual(0, backingStore.Count);

                    Hashtable isolatedStorageContents = backingStore.Load();
                    Assert.AreEqual(0, isolatedStorageContents.Count);
                }
            }
        }
		public void ExceptionThrownDuringAddIntoIsolatedStorageAllowsItemToBeReaddedLater()
		{
			using (IsolatedStorageBackingStore backingStore = new IsolatedStorageBackingStore("foo", null))
			{
				ICachingInstrumentationProvider instrumentationProvider = new NullCachingInstrumentationProvider();

				Cache cache = new Cache(backingStore, instrumentationProvider);

				try
				{
					try
					{
						cache.Add("my", new NonSerializableClass());
						Assert.Fail("Should have thrown exception internally to Cache.Add");
					}
					catch (Exception)
					{
						cache.Add("my", new SerializableClass());
						Assert.IsTrue(cache.Contains("my"));
					}
				}
				finally
				{
					backingStore.Flush();
				}
			}
		}
        public void ExceptionThrownDuringAddIntoIsolatedStorageAllowsItemToBeReaddedLater()
        {
            using (IsolatedStorageBackingStore backingStore = new IsolatedStorageBackingStore("foo", null))
            {
                CacheCapacityScavengingPolicy scavengingPolicy = new CacheCapacityScavengingPolicy(10);
                CachingInstrumentationProvider instrumentationProvider = new CachingInstrumentationProvider();

                Cache cache = new Cache(backingStore, scavengingPolicy, instrumentationProvider);
                cache.Initialize(this);

                try
                {
                    cache.Add("my", new NonSerializableClass());
                    Assert.Fail("Should have thrown exception internally to Cache.Add");
                }
                catch (Exception)
                {
                    cache.Add("my", new SerializableClass());
                    Assert.IsTrue(cache.Contains("my"));
                }
            }
        }
        public void ExceptionThrownDuringAddIntoIsolatedStorageAllowsItemToBeReaddedLater()
        {
            TestConfigurationContext context = new TestConfigurationContext();
            using (IsolatedStorageBackingStore backingStore = new IsolatedStorageBackingStore("foo"))
            {
                CacheCapacityScavengingPolicy scavengingPolicy = new CacheCapacityScavengingPolicy("test", new CachingConfigurationView(context));

                Cache cache = new Cache(backingStore, scavengingPolicy);
                cache.Initialize(this);

                try
                {
                    cache.Add("my", new NonSerializableClass());
                    Assert.Fail("Should have thrown exception internally to Cache.Add");
                }
                catch (Exception)
                {
                    cache.Add("my", new SerializableClass());
                    Assert.IsTrue(cache.Contains("my"));
                }
            }
        }