public void CanDeserializeSerializedConfiguration() { CacheManagerSettings settings = new CacheManagerSettings(); DataCacheStorageData data1 = new DataCacheStorageData(name1, database1, partition1); settings.BackingStores.Add(data1); // needed to save configuration settings.CacheManagers.Add(new CacheManagerData("foo", 0, 0, 0, "storage")); IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(); 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(name1)); Assert.AreSame(typeof(DataCacheStorageData), roSettigs.BackingStores.Get(name1).GetType()); Assert.AreEqual(name1, roSettigs.BackingStores.Get(name1).Name); Assert.AreEqual(database1, ((DataCacheStorageData)roSettigs.BackingStores.Get(name1)).DatabaseInstanceName); Assert.AreEqual(partition1, ((DataCacheStorageData)roSettigs.BackingStores.Get(name1)).PartitionName); //Assert.AreEqual(encryption1, ((DataCacheStorageData)roSettigs.BackingStores.Get(name1)).StorageEncryption); }
public StoreInDatabase(ICachingConfigurationCacheManager context, string backingStoreName) : base(context) { dataCacheStore = new DataCacheStorageData { Name = backingStoreName }; base.AddBackingStoreToCachingConfigurationAndCurrentCacheManager(dataCacheStore); }
public void CanConstructDataCacheStorageDataCorrectly() { const string name = "name"; const string instance = "instance"; const string partition = "partition"; DataCacheStorageData data = new DataCacheStorageData(name, instance, partition); Assert.AreEqual(name, data.Name); Assert.AreEqual(instance, data.DatabaseInstanceName); Assert.AreEqual(partition, data.PartitionName); Assert.AreEqual(typeof(DataBackingStore), data.Type); }
public override void FixtureSetup() { base.FixtureSetup (); DataCacheStorageData firstCacheData = new DataCacheStorageData(); firstCacheData.DatabaseInstanceName = "CachingDatabase"; firstCacheData.PartitionName = "Partition1"; firstCache = new DataBackingStore(); firstCache.Initialize(new TestCachingConfigurationView(firstCacheData, Context)); DataCacheStorageData secondCacheData = new DataCacheStorageData(); secondCacheData.DatabaseInstanceName = "CachingDatabase"; secondCacheData.PartitionName = "Partition2"; secondCache = new DataBackingStore(); secondCache.Initialize(new TestCachingConfigurationView(secondCacheData, Context)); }
/// <summary> /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. /// Builds an <see cref="DataBackingStore"/> based on an instance of <see cref="DataCacheStorageData"/>. /// </summary> /// <seealso cref="BackingStoreCustomFactory"/> /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param> /// <param name="objectConfiguration">The configuration object that describes the object to build. Must be an instance of <see cref="DataCacheStorageData"/>.</param> /// <param name="configurationSource">The source for configuration objects.</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>A fully initialized instance of <see cref="DataBackingStore"/>.</returns> public IBackingStore Assemble(IBuilderContext context, CacheStorageData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { DataCacheStorageData castedObjectConfiguration = (DataCacheStorageData)objectConfiguration; Data.Database database = (Data.Database)context.HeadOfChain.BuildUp(context, typeof(Data.Database), null, castedObjectConfiguration.DatabaseInstanceName); IStorageEncryptionProvider encryptionProvider = GetStorageEncryptionProvider(context, castedObjectConfiguration.StorageEncryption, configurationSource, reflectionCache); IBackingStore createdObjet = new DataBackingStore( database, castedObjectConfiguration.PartitionName, encryptionProvider); return(createdObjet); }
public void CanResolveDataBackingStoreWithOutEncryptionProvider() { const string key = "fooKey"; DataCacheStorageData data = new DataCacheStorageData("Data Cache Storage", "CachingDatabase", "fooPartition"); settings.BackingStores.Add(data); CacheManagerData managerData = new CacheManagerData("defaultCacheManager", 300, 200, 100, "Data Cache Storage"); settings.CacheManagers.Add(managerData); settings.DefaultCacheManager = "defaultCacheManager"; dbSettings.DefaultDatabase = "CachingDatabase"; container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource); DataBackingStore createdStore = container.GetInstance<DataBackingStore>("Data Cache Storage"); Assert.IsNotNull(createdStore); createdStore.Add(new CacheItem(key, 1, CacheItemPriority.Low, null, null)); Assert.AreEqual(1, createdStore.Count); createdStore.Remove(key); Assert.AreEqual(0, createdStore.Count); }
private DataBackingStore CreateDataBackingStore() { DataCacheStorageData data = new DataCacheStorageData(); data.DatabaseInstanceName = "CachingDatabase"; data.PartitionName = "Partition1"; DataBackingStore backingStore = new DataBackingStore(); backingStore.Initialize(new TestCachingConfigurationView(data, Context)); return backingStore; }
private DataBackingStore CreateBackingStore(string instanceName, string partitionName) { DataCacheStorageData data = new DataCacheStorageData(); data.DatabaseInstanceName = instanceName; data.PartitionName = partitionName; DataBackingStore backingStore = new DataBackingStore(); backingStore.Initialize(new TestCachingConfigurationView(data, Context)); return backingStore; }