public void CanDeserializeSerializedConfiguration()
        {
            CustomCacheStorageData customData
                = new CustomCacheStorageData("custom", typeof(MockCustomStorageBackingStore));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            CacheManagerSettings settings = new CacheManagerSettings();
            settings.BackingStores.Add(customData);
            settings.CacheManagers.Add(new CacheManagerData("ignore", 0, 0, 0, "custom"));

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(1);
            sections[CacheManagerSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            CacheManagerSettings roSettigs = (CacheManagerSettings)configurationSource.GetSection(CacheManagerSettings.SectionName);

            Assert.IsNotNull(roSettigs);
            Assert.AreEqual(1, roSettigs.BackingStores.Count);

            Assert.IsNotNull(roSettigs.BackingStores.Get("custom"));
            Assert.AreSame(typeof(CustomCacheStorageData), roSettigs.BackingStores.Get("custom").GetType());
            Assert.AreEqual("custom", ((CustomCacheStorageData)roSettigs.BackingStores.Get("custom")).Name);
            Assert.AreEqual(typeof(MockCustomStorageBackingStore), ((CustomCacheStorageData)roSettigs.BackingStores.Get("custom")).Type);
            Assert.AreEqual("value1", ((CustomCacheStorageData)roSettigs.BackingStores.Get("custom")).Attributes[MockCustomProviderBase.AttributeKey]);
        }
        public void CanCreateCustomCacheStorage()
        {
            CustomCacheStorageData data = new CustomCacheStorageData("name", typeof(MockCustomStorageBackingStore));
            data.Attributes[MockCustomStorageBackingStore.AttributeKey] = "value1";
            settings.BackingStores.Add(data);

            IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource);

            MockCustomStorageBackingStore createdObject = (MockCustomStorageBackingStore)container.GetInstance<IBackingStore>("name");

            Assert.IsNotNull(createdObject);
            Assert.AreEqual("value1", createdObject.customValue);
        }
        public void CanBuildCustomBackingStoreFromGivenConfiguration()
        {
            CustomCacheStorageData customData
                = new CustomCacheStorageData("custom", typeof(MockCustomStorageBackingStore));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            CacheManagerSettings settings = new CacheManagerSettings();
            settings.BackingStores.Add(customData);
            settings.CacheManagers.Add(new CacheManagerData("ignore", 0, 0, 0, "custom"));
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            configurationSource.Add(CacheManagerSettings.SectionName, settings);

            IBackingStore custom
                = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance<IBackingStore>("custom");

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomStorageBackingStore), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomStorageBackingStore)custom).customValue);
        }
		public void CanBuildCustomBackingStoreFromSavedConfiguration()
		{
			CustomCacheStorageData customData
				= new CustomCacheStorageData("custom", typeof(MockCustomStorageBackingStore));
			customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
			CacheManagerSettings settings = new CacheManagerSettings();
			settings.BackingStores.Add(customData);
			settings.CacheManagers.Add(new CacheManagerData("ignore", 0, 0, 0, "custom"));

			IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(1);
			sections[CacheManagerSettings.SectionName] = settings;
			IConfigurationSource configurationSource 
				= ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

			IBackingStore custom
				= EnterpriseLibraryFactory.BuildUp<IBackingStore>("custom", configurationSource);

			Assert.IsNotNull(custom);
			Assert.AreSame(typeof(MockCustomStorageBackingStore), custom.GetType());
			Assert.AreEqual("value1", ((MockCustomStorageBackingStore)custom).customValue);
		}
        public void Setup()
        {
            CustomCacheStorageData customStoreData = new CustomCacheStorageData();
            customStoreData.Name = "Custom Store";
            customStoreData.Type = typeof(FaultyType);

            settings = new CacheManagerSettings();
            settings.BackingStores.Add(customStoreData);
        }
        public void Setup()
        {
            CustomCacheStorageData customStorageData = new CustomCacheStorageData("Custom Storage", typeof(MockCustomStorageBackingStore));
            CacheManagerData cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, customStorageData.Name);

            CacheManagerSettings settings = new CacheManagerSettings();
            settings.CacheManagers.Add(cacheManagerData);
            settings.BackingStores.Add(customStorageData);

            registrations = settings.GetRegistrations(null);
        }