public void CustomCacheManagerWithDisabledPolicyIsRemoved() { CustomCacheManagerData data1 = new CustomCacheManagerData(); data1.Name = "cache manager 1"; data1.Type = typeof(object); data1.Attributes.Add("key1", "value1"); section.CacheManagers.Add(data1); CustomCacheManagerData data2 = new CustomCacheManagerData(); data2.Name = "cache manager 2"; data2.Type = typeof(object); data2.Attributes.Add("key11", "value11"); section.CacheManagers.Add(data2); MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey); MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false); machineCacheManagersKey.AddSubKey("cache manager 1", machineCacheManager1Key); machineCacheManager1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(1, section.CacheManagers.Count); Assert.IsNotNull(section.CacheManagers.Get("cache manager 2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key)); }
public void ManageabilityProviderGeneratesProperAdmContentWithCustomCacheManager() { DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); configurationSource.Add(CacheManagerSettings.SectionName, section); CustomCacheManagerData manager1, manager2; section.CacheManagers.Add(manager1 = new CustomCacheManagerData("manager1", typeof(object))); section.CacheManagers.Add(manager2 = new CustomCacheManagerData("manager2", typeof(object))); MockAdmContentBuilder contentBuilder = new MockAdmContentBuilder(); provider.AddAdministrativeTemplateDirectives(contentBuilder, section, configurationSource, "TestApp"); MockAdmContent content = contentBuilder.GetMockContent(); IEnumerator <AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator(); Assert.IsTrue(categoriesEnumerator.MoveNext()); IEnumerator <AdmCategory> subCategoriesEnumerator = categoriesEnumerator.Current.Categories.GetEnumerator(); Assert.IsTrue(subCategoriesEnumerator.MoveNext()); IEnumerator <AdmPolicy> cacheManagerPoliciesEnumerator = subCategoriesEnumerator.Current.Policies.GetEnumerator(); Assert.IsTrue(cacheManagerPoliciesEnumerator.MoveNext()); Assert.IsTrue(cacheManagerPoliciesEnumerator.MoveNext()); Assert.IsFalse(cacheManagerPoliciesEnumerator.MoveNext()); Assert.IsFalse(subCategoriesEnumerator.MoveNext()); IEnumerator <AdmPolicy> sectionPoliciesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator(); Assert.IsTrue(sectionPoliciesEnumerator.MoveNext()); Assert.IsFalse(sectionPoliciesEnumerator.MoveNext()); Assert.IsFalse(categoriesEnumerator.MoveNext()); }
public void SetUp() { provider = new CustomCacheManagerDataManageabilityProvider(); machineKey = new MockRegistryKey(true); userKey = new MockRegistryKey(true); configurationObject = new CustomCacheManagerData(); }
public void CanDeserializeSerializedConfiguration() { CustomCacheManagerData customData = new CustomCacheManagerData("custom", typeof(CustomCacheManager)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(customData); 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.CacheManagers.Count); Assert.IsNotNull(roSettigs.CacheManagers.Get("custom")); Assert.AreSame(typeof(CustomCacheManagerData), roSettigs.CacheManagers.Get("custom").GetType()); Assert.AreEqual("custom", ((CustomCacheManagerData)roSettigs.CacheManagers.Get("custom")).Name); Assert.AreEqual(typeof(CustomCacheManager), ((CustomCacheManagerData)roSettigs.CacheManagers.Get("custom")).Type); Assert.AreEqual("value1", ((CustomCacheManagerData)roSettigs.CacheManagers.Get("custom")).Attributes[MockCustomProviderBase.AttributeKey]); }
public static void GenerateWmiObjects(CustomCacheManagerData data, ICollection <ConfigurationSetting> wmiSettings) { wmiSettings.Add( new CustomCacheManagerSetting(data.Name, data.Type.AssemblyQualifiedName, CustomDataWmiMapperHelper.GenerateAttributesArray(data.Attributes))); }
public void Setup() { CustomCacheManagerData customCacheManager = new CustomCacheManagerData(); customCacheManager.Name = "Custom Cache Manager"; customCacheManager.Type = typeof(FaultyType); settings = new CacheManagerSettings(); settings.CacheManagers.Add(customCacheManager); }
public ForCustomCacheManagerNamedBuilder(ICachingConfiguration context, string cacheManagerName, Type customCacheManagerType, NameValueCollection attributes) : base(context) { cacheManagerData = new CustomCacheManagerData { Name = cacheManagerName, Type = customCacheManagerType }; cacheManagerData.Attributes.Add(attributes); base.CachingSettings.CacheManagers.Add(cacheManagerData); }
public void CanCreateCustomCacheManager() { CustomCacheManagerData data = new CustomCacheManagerData("name", typeof(CustomCacheManager)); data.Attributes[MockCustomStorageBackingStore.AttributeKey] = "value1"; settings.CacheManagers.Add(data); IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource); CustomCacheManager createdObject = (CustomCacheManager)container.GetInstance <ICacheManager>("name"); Assert.IsNotNull(createdObject); Assert.AreEqual("value1", createdObject.customValue); }
public void CheckLifetime() { CustomCacheManagerData data = new CustomCacheManagerData("name", typeof(CustomCacheManager)); settings.CacheManagers.Add(data); CustomCacheManager createdObject = null; IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource); createdObject = (CustomCacheManager)container.GetInstance <ICacheManager>("name"); Assert.IsFalse(createdObject.wasDisposed); container.Dispose(); Assert.IsTrue(createdObject.wasDisposed); }
public void Setup() { CustomCacheManagerData customCacheManager = new CustomCacheManagerData("Custom Cache Manager", typeof(CustomCacheManager)); CacheStorageData cacheStorageData = new CacheStorageData("Null Storage", typeof(NullBackingStore)); CacheManagerData cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, cacheStorageData.Name); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(cacheManagerData); settings.BackingStores.Add(cacheStorageData); settings.CacheManagers.Add(customCacheManager); registrations = settings.GetRegistrations(null); }
public void CustomCacheManagerIsNotOverridenIfThereAreNoPolicyOverrides() { CustomCacheManagerData data1 = new CustomCacheManagerData(); data1.Name = "cache manager 1"; data1.Type = typeof(object); data1.Attributes.Add("key1", "value1"); data1.Attributes.Add("key2", "value2"); section.CacheManagers.Add(data1); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual("value1", data1.Attributes["key1"]); Assert.AreEqual("value2", data1.Attributes["key2"]); }
public void CanBuildCustomCacheManagerFromGivenConfiguration() { CustomCacheManagerData customData = new CustomCacheManagerData("custom", typeof(CustomCacheManager)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(customData); DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); configurationSource.Add(CacheManagerSettings.SectionName, settings); ICacheManager custom = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance<ICacheManager>("custom"); Assert.IsNotNull(custom); Assert.AreSame(typeof(CustomCacheManager), custom.GetType()); Assert.AreEqual("value1", ((CustomCacheManager)custom).customValue); }
public void CanBuildCustomCacheManagerFromSavedConfiguration() { CustomCacheManagerData customData = new CustomCacheManagerData("custom", typeof(CustomCacheManager)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(customData); IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(1); sections[CacheManagerSettings.SectionName] = settings; IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); ICacheManager custom = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance<ICacheManager>("custom"); Assert.IsNotNull(custom); Assert.AreSame(typeof(CustomCacheManager), custom.GetType()); Assert.AreEqual("value1", ((CustomCacheManager)custom).customValue); }
public void CanBuildCustomCacheManagerFromGivenConfiguration() { CustomCacheManagerData customData = new CustomCacheManagerData("custom", typeof(CustomCacheManager)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(customData); DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); configurationSource.Add(CacheManagerSettings.SectionName, settings); ICacheManager custom = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance <ICacheManager>("custom"); Assert.IsNotNull(custom); Assert.AreSame(typeof(CustomCacheManager), custom.GetType()); Assert.AreEqual("value1", ((CustomCacheManager)custom).customValue); }
public void CanBuildCustomCacheManagerFromSavedConfiguration() { CustomCacheManagerData customData = new CustomCacheManagerData("custom", typeof(CustomCacheManager)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(customData); IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(1); sections[CacheManagerSettings.SectionName] = settings; IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); ICacheManager custom = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance <ICacheManager>("custom"); Assert.IsNotNull(custom); Assert.AreSame(typeof(CustomCacheManager), custom.GetType()); Assert.AreEqual("value1", ((CustomCacheManager)custom).customValue); }
public void CanDeserializeSerializedConfiguration() { CustomCacheManagerData customData = new CustomCacheManagerData("custom", typeof(CustomCacheManager)); customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1"); CacheManagerSettings settings = new CacheManagerSettings(); settings.CacheManagers.Add(customData); 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.CacheManagers.Count); Assert.IsNotNull(roSettigs.CacheManagers.Get("custom")); Assert.AreSame(typeof(CustomCacheManagerData), roSettigs.CacheManagers.Get("custom").GetType()); Assert.AreEqual("custom", ((CustomCacheManagerData)roSettigs.CacheManagers.Get("custom")).Name); Assert.AreEqual(typeof(CustomCacheManager), ((CustomCacheManagerData)roSettigs.CacheManagers.Get("custom")).Type); Assert.AreEqual("value1", ((CustomCacheManagerData)roSettigs.CacheManagers.Get("custom")).Attributes[MockCustomProviderBase.AttributeKey]); }
public void ManageabilityProviderGeneratesProperAdmContentWithCustomCacheManager() { DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); configurationSource.Add(CacheManagerSettings.SectionName, section); CustomCacheManagerData manager1, manager2; section.CacheManagers.Add(manager1 = new CustomCacheManagerData("manager1", typeof(object))); section.CacheManagers.Add(manager2 = new CustomCacheManagerData("manager2", typeof(object))); MockAdmContentBuilder contentBuilder = new MockAdmContentBuilder(); provider.AddAdministrativeTemplateDirectives(contentBuilder, section, configurationSource, "TestApp"); MockAdmContent content = contentBuilder.GetMockContent(); IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator(); Assert.IsTrue(categoriesEnumerator.MoveNext()); IEnumerator<AdmCategory> subCategoriesEnumerator = categoriesEnumerator.Current.Categories.GetEnumerator(); Assert.IsTrue(subCategoriesEnumerator.MoveNext()); IEnumerator<AdmPolicy> cacheManagerPoliciesEnumerator = subCategoriesEnumerator.Current.Policies.GetEnumerator(); Assert.IsTrue(cacheManagerPoliciesEnumerator.MoveNext()); Assert.IsTrue(cacheManagerPoliciesEnumerator.MoveNext()); Assert.IsFalse(cacheManagerPoliciesEnumerator.MoveNext()); Assert.IsFalse(subCategoriesEnumerator.MoveNext()); IEnumerator<AdmPolicy> sectionPoliciesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator(); Assert.IsTrue(sectionPoliciesEnumerator.MoveNext()); Assert.IsFalse(sectionPoliciesEnumerator.MoveNext()); Assert.IsFalse(categoriesEnumerator.MoveNext()); }
public void CheckLifetime() { CustomCacheManagerData data = new CustomCacheManagerData("name", typeof(CustomCacheManager)); settings.CacheManagers.Add(data); CustomCacheManager createdObject = null; IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource); createdObject = (CustomCacheManager) container.GetInstance<ICacheManager>("name"); Assert.IsFalse(createdObject.wasDisposed); container.Dispose(); Assert.IsTrue(createdObject.wasDisposed); }
public void CanCreateCustomCacheManager() { CustomCacheManagerData data = new CustomCacheManagerData("name", typeof(CustomCacheManager)); data.Attributes[MockCustomStorageBackingStore.AttributeKey] = "value1"; settings.CacheManagers.Add(data); IServiceLocator container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource); CustomCacheManager createdObject = (CustomCacheManager)container.GetInstance<ICacheManager>("name"); Assert.IsNotNull(createdObject); Assert.AreEqual("value1", createdObject.customValue); }