public void CustomNodeTest() { string name = "testName"; string type = "testType"; NameValueItemCollection extensions = new NameValueItemCollection(); extensions.Add(new NameValueItem("test", "value")); CustomCacheStorageNode node = new CustomCacheStorageNode(); applicationNode.Nodes.Add(node); Assert.AreEqual(SR.DefaultCacheStorageNodeName, node.Name); node.Type = type; Assert.AreEqual(type, node.Type); node.Name = name; Assert.AreEqual(name, node.Name); node.Extensions.Add(extensions[0]); Assert.AreEqual(extensions[0], node.Extensions[0]); CustomCacheStorageData nodeData = (CustomCacheStorageData)node.CacheStorageData; Assert.AreEqual(name, nodeData.Name); Assert.AreEqual(type, nodeData.TypeName); Assert.AreEqual(extensions[0], nodeData.Extensions[0]); }
public void CustomCacheStorageNodeTest() { string name = "testName1"; Type type = typeof(CustomCacheStorageData); NameValueCollection attributes = new NameValueCollection(); attributes.Add("test", "value"); CustomCacheStorageNode node = new CustomCacheStorageNode(); ApplicationNode.AddNode(node); Assert.AreEqual("Cache Storage", node.Name); node.Type = type; node.Name = name; node.Attributes.Add(new EditableKeyValue(attributes.GetKey(0), attributes[attributes.GetKey(0)])); Assert.AreEqual(attributes[0], node.Attributes[0].Value); Assert.AreEqual(type, node.Type); Assert.AreEqual(name, node.Name); CustomCacheStorageData nodeData = (CustomCacheStorageData)node.CacheStorageData; Assert.AreEqual(name, nodeData.Name); Assert.AreEqual(type, nodeData.Type); Assert.AreEqual(attributes.AllKeys[0], nodeData.Attributes.AllKeys[0]); Assert.AreEqual(attributes.Get(0), nodeData.Attributes.Get(0)); }
public void SetUp() { provider = new CustomCacheStorageDataManageabilityProvider(); machineKey = new MockRegistryKey(true); userKey = new MockRegistryKey(true); configurationObject = new CustomCacheStorageData(); }
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 DataTest() { string name = "testName"; CacheStorageData cacheStorage = new CustomCacheStorageData(); cacheStorage.Name = "testCacheStorageName"; cacheStorage.TypeName = "fakeType"; int expirationPollFrequencyInSeconds = 30; int maximumElementsInCacheBeforeScavenging = 5; int numberToRemoveWhenScavenging = 8; CacheManagerData data = new CacheManagerData(); data.Name = name; data.CacheStorage = cacheStorage; data.ExpirationPollFrequencyInSeconds = expirationPollFrequencyInSeconds; data.MaximumElementsInCacheBeforeScavenging = maximumElementsInCacheBeforeScavenging; data.NumberToRemoveWhenScavenging = numberToRemoveWhenScavenging; data.CacheStorage = cacheStorage; CacheManagerNode node = new CacheManagerNode(data); applicationNode.Nodes.Add(node); CacheManagerData nodeData = node.CacheManagerData; Assert.AreEqual(name, nodeData.Name); Assert.AreEqual(expirationPollFrequencyInSeconds, nodeData.ExpirationPollFrequencyInSeconds); Assert.AreEqual(maximumElementsInCacheBeforeScavenging, nodeData.MaximumElementsInCacheBeforeScavenging); Assert.AreEqual(numberToRemoveWhenScavenging, nodeData.NumberToRemoveWhenScavenging); Assert.AreEqual(cacheStorage.Name, nodeData.CacheStorage.Name); Assert.AreEqual(cacheStorage.TypeName, nodeData.CacheStorage.TypeName); }
public void DataTest() { CacheStorageData cacheStorage = new CustomCacheStorageData(); cacheStorage.Name = "testCacheStorage"; CacheManagerDataCollection cacheManagers = new CacheManagerDataCollection(); CacheManagerData testManager1 = new CacheManagerData(); testManager1.Name = "testName"; testManager1.CacheStorage = cacheStorage; cacheManagers.Add(testManager1); CacheManagerSettings data = new CacheManagerSettings(); data.CacheManagers.Clear(); data.CacheManagers.AddRange(cacheManagers); CacheManagerSettingsNode node = new CacheManagerSettingsNode(data); applicationNode.Nodes.Add(node); CacheManagerSettings nodeData = node.CacheManagerSettings; Assert.AreSame(testManager1, nodeData.CacheManagers[testManager1.Name]); }
public static void GenerateWmiObjects(CustomCacheStorageData data, ICollection <ConfigurationSetting> wmiSettings) { wmiSettings.Add( new CustomCacheStorageSetting(data.Name, data.Type.AssemblyQualifiedName, CustomDataWmiMapperHelper.GenerateAttributesArray(data.Attributes))); }
public void SetUp() { provider = new ConfigurationElementManageabilityProviderWrapper(new CustomCacheStorageDataManageabilityProvider()); machineKey = new MockRegistryKey(true); userKey = new MockRegistryKey(true); wmiSettings = new List <ConfigurationSetting>(); configurationObject = new CustomCacheStorageData(); }
public void Setup() { CustomCacheStorageData customStoreData = new CustomCacheStorageData(); customStoreData.Name = "Custom Store"; customStoreData.Type = typeof(FaultyType); settings = new CacheManagerSettings(); settings.BackingStores.Add(customStoreData); }
/// <summary> /// Initialize a new instance of the <see cref="CustomCacheStorageNode"/> class with a <see cref="CustomCacheStorageData"/> object. /// </summary> /// <param name="customCacheStorageData">The <see cref="CustomCacheStorageData"/> to display.</param> public CustomCacheStorageNode(CustomCacheStorageData customCacheStorageData) { if (null == customCacheStorageData) throw new ArgumentNullException("customCacheStorageData"); Rename(customCacheStorageData.Name); foreach (string key in customCacheStorageData.Attributes) { editableAttributes.Add(new EditableKeyValue(key, customCacheStorageData.Attributes[key])); } this.type = customCacheStorageData.Type; }
public void CanReadCacheStorageObject() { XmlTextReader xmlReader = new XmlTextReader(new StringReader(configurationSection)); XmlSerializer xmlSerializer = new XmlSerializer(typeof(CustomCacheStorageData)); CustomCacheStorageData objectFromConfiguration = xmlSerializer.Deserialize(xmlReader) as CustomCacheStorageData; Assert.AreEqual("inIsolatedStorage", objectFromConfiguration.Name); Assert.AreEqual("TestType", objectFromConfiguration.TypeName); Assert.AreEqual("testValue", objectFromConfiguration.Extensions["testName"]); Assert.AreEqual(1, objectFromConfiguration.Extensions.Count); }
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); }
public StoreInCustomStoreBuilder(ICachingConfigurationCacheManager context, string backingStoreName, Type customCacheStoreType, NameValueCollection attributes) : base(context) { customCacheStorageData = new CustomCacheStorageData { Name = backingStoreName, Type = customCacheStoreType }; customCacheStorageData.Attributes.Add(attributes); base.AddBackingStoreToCachingConfigurationAndCurrentCacheManager(customCacheStorageData); }
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); }
/// <summary> /// Initialize a new instance of the <see cref="CustomCacheStorageNode"/> class with a <see cref="CustomCacheStorageData"/> object. /// </summary> /// <param name="customCacheStorageData">The <see cref="CustomCacheStorageData"/> to display.</param> public CustomCacheStorageNode(CustomCacheStorageData customCacheStorageData) { if (null == customCacheStorageData) { throw new ArgumentNullException("customCacheStorageData"); } Rename(customCacheStorageData.Name); foreach (string key in customCacheStorageData.Attributes) { editableAttributes.Add(new EditableKeyValue(key, customCacheStorageData.Attributes[key])); } this.typeName = customCacheStorageData.TypeName; }
private CacheStorageData GetCacheStorageData() { CacheStorageData cacheStorageData; if (Nodes.Count == 0) { cacheStorageData = new CustomCacheStorageData(SR.NullStorageName, NullBackingStoreTypeName); } else { cacheStorageData = ((CacheStorageNode)Nodes[0]).CacheStorageData; } return(cacheStorageData); }
public void CustomDataTest() { string name = "testName"; string type = "testType"; NameValueItemCollection extensions = new NameValueItemCollection(); extensions.Add(new NameValueItem("test", "value")); CustomCacheStorageData data = new CustomCacheStorageData(); data.Name = name; data.TypeName = type; data.Extensions.Add(extensions[0]); CustomCacheStorageNode node = new CustomCacheStorageNode(data); applicationNode.Nodes.Add(node); Assert.AreEqual(name, node.Name); Assert.AreEqual(type, node.Type); Assert.AreEqual(extensions[0], node.Extensions[0]); }
public void DataTest() { CacheStorageData cacheStorage = new CustomCacheStorageData(); cacheStorage.Name = "testevtu8entv"; CacheManagerDataCollection data = new CacheManagerDataCollection(); CacheManagerData cacheManagerData = new CacheManagerData(); cacheManagerData.CacheStorage = cacheStorage; cacheManagerData.Name = "tesotvetyevt"; data.Add(cacheManagerData); CacheManagerCollectionNode node = new CacheManagerCollectionNode(data); applicationNode.Nodes.Add(node); CacheManagerDataCollection nodeData = node.CacheManagerDataCollection; Assert.AreEqual(data.Count, nodeData.Count); Assert.AreEqual(data[cacheManagerData.Name].CacheStorage.Name, nodeData[cacheManagerData.Name].CacheStorage.Name); }
public void CustomCacheStorageDataTest() { string name = "testName2"; Type type = typeof(CacheStorageNodeFixture); NameValueCollection attributes = new NameValueCollection(); attributes.Add("test", "value"); CustomCacheStorageData data = new CustomCacheStorageData(); data.Name = name; data.Type = type; data.Attributes.Add(attributes.GetKey(0), attributes[attributes.GetKey(0)]); CustomCacheStorageNode node = new CustomCacheStorageNode(data); ApplicationNode.AddNode(node); Assert.AreEqual(name, node.Name); Assert.AreEqual(type, node.Type); Assert.AreEqual(attributes.AllKeys[0], node.Attributes[0].Key); Assert.AreEqual(attributes.Get(0), node.Attributes[0].Value); }
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); }
private CacheStorageData GetCacheStorageData() { CacheStorageData cacheStorageData; if (Nodes.Count == 0) { cacheStorageData = new CustomCacheStorageData(SR.NullStorageName, NullBackingStoreTypeName); } else { cacheStorageData = ((CacheStorageNode)Nodes[0]).CacheStorageData; } return cacheStorageData; }
/// <summary> /// Initialize a new instance of the <see cref="CustomCacheStorageNode"/> with the <see cref="CustomCacheStorageData"/>. /// </summary> /// <param name="customCacheStorageData">The <see cref="CustomCacheStorageData"/>.</param> public CustomCacheStorageNode(CustomCacheStorageData customCacheStorageData) : base(customCacheStorageData) { this.customCacheStorageData = customCacheStorageData; }