public void OpenAndSaveTest() { GeneratedHierarchy.Load(); Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count); GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count); CacheManagerSettingsNode rootNode = (CacheManagerSettingsNode)GeneratedHierarchy.FindNodeByType(typeof(CacheManagerSettingsNode)); Assert.IsNotNull(rootNode); Assert.AreEqual("InMemoryPersistence", rootNode.DefaultCacheManager.Name); rootNode.DefaultCacheManager.Name = "BadData"; GeneratedHierarchy.Save(); Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count); ApplicationData data = ApplicationData.FromCurrentAppDomain(); ApplicationConfigurationNode applicationNode = new ApplicationConfigurationNode(data); IUIHierarchy newHierarchy = CreateHierarchyAndAddToHierarchyService(applicationNode, CreateDefaultConfiguration()); HierarchyService.SelectedHierarchy = newHierarchy; newHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorLogService.ConfigurationErrors.Count); rootNode = (CacheManagerSettingsNode)newHierarchy.FindNodeByType(typeof(CacheManagerSettingsNode)); Assert.AreEqual("BadData", rootNode.DefaultCacheManager.Name); rootNode.DefaultCacheManager.Name = "InMemoryPersistence"; newHierarchy.Save(); }
public void RenamingOneDistributionStrategyLeavesOnlyOneStrategy() { string name = "Test Custom Strategy 1"; GeneratedHierarchy.Open(); LoggingSettingsNode node = new LoggingSettingsNode(); GeneratedApplicationNode.Nodes.AddWithDefaultChildren(node); DistributionStrategyCollectionNode distributionStrategyCollectionNode = GeneratedHierarchy.FindNodeByType(typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode; Assert.IsNotNull(distributionStrategyCollectionNode); distributionStrategyCollectionNode.Nodes.Clear(); CustomDistributionStrategyNode customNode = new CustomDistributionStrategyNode(); distributionStrategyCollectionNode.Nodes.AddWithDefaultChildren(customNode); customNode.TypeName = typeof(InProcDistributionStrategyData).AssemblyQualifiedName; customNode.Name = name; GeneratedHierarchy.Save(); ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain()); IUIHierarchy hierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration()); HierarchyService.SelectedHierarchy = hierarchy; hierarchy.Open(); LoggingSettingsNode settingsNode = hierarchy.FindNodeByType(typeof(LoggingSettingsNode)) as LoggingSettingsNode; Assert.IsNotNull(settingsNode); distributionStrategyCollectionNode = hierarchy.FindNodeByType(appNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode; Assert.IsNotNull(distributionStrategyCollectionNode); ConfigurationNode [] nodes = hierarchy.FindNodesByType(distributionStrategyCollectionNode, typeof(CustomDistributionStrategyNode)); Assert.AreEqual(1, nodes.Length); Assert.AreEqual(name, nodes[0].Name); }
public void RegisterXmlIncludeTypeTest() { DataCacheStorageNode node = new DataCacheStorageNode(); CreateHierarchyAndAddToHierarchyService(node, CreateDefaultConfiguration()); GeneratedHierarchy.Open(); Type[] types = XmlIncludeTypeService.GetXmlIncludeTypes(CacheManagerSettings.SectionName); Assert.AreEqual(1, types.Length); Assert.AreEqual(typeof(DataCacheStorageData), types[0]); }
public void BuildContextTest() { ClientLoggingConfigurationDesignManager b = new ClientLoggingConfigurationDesignManager(); GeneratedHierarchy.Open(); ConfigurationDictionary dictionary = new ConfigurationDictionary(); b.BuildContext(Host, dictionary); Assert.AreEqual(1, dictionary.Count); Assert.IsTrue(dictionary.Contains(LoggingSettings.SectionName)); }
public void RemovingDistributionStrategySavesAndReopensCorrectly() { GeneratedHierarchy.Open(); LoggingSettingsNode node = new LoggingSettingsNode(); GeneratedApplicationNode.Nodes.AddWithDefaultChildren(node); ClientSettingsNode clientSettingsNode = GeneratedHierarchy.FindNodeByType(node, typeof(ClientSettingsNode)) as ClientSettingsNode; DistributionStrategyCollectionNode distributions = GeneratedHierarchy.FindNodeByType(clientSettingsNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode; distributions.Nodes.AddWithDefaultChildren(new MsmqDistributionStrategyNode()); GeneratedHierarchy.Save(); ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain()); IUIHierarchy hierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration()); HierarchyService.SelectedHierarchy = hierarchy; hierarchy.Open(); LoggingSettingsNode settingsNode = hierarchy.FindNodeByType(typeof(LoggingSettingsNode)) as LoggingSettingsNode; Assert.IsNotNull(settingsNode); distributions = hierarchy.FindNodeByType(appNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode; Assert.IsNotNull(distributions); MsmqDistributionStrategyNode msmqDistributionStrategyNode = hierarchy.FindNodeByType(distributions, typeof(MsmqDistributionStrategyNode)) as MsmqDistributionStrategyNode; Assert.IsNotNull(msmqDistributionStrategyNode); // expect 3, inproc, MSMQ, and custom Assert.AreEqual(3, distributions.Nodes.Count); InProcDistributionStrategyNode inProcNode = hierarchy.FindNodeByType(distributions, typeof(InProcDistributionStrategyNode)) as InProcDistributionStrategyNode; Assert.IsNotNull(inProcNode); inProcNode.Remove(); hierarchy.Save(); appNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain()); hierarchy = CreateHierarchyAndAddToHierarchyService(appNode, CreateDefaultConfiguration()); HierarchyService.SelectedHierarchy = hierarchy; hierarchy.Open(); settingsNode = hierarchy.FindNodeByType(typeof(LoggingSettingsNode)) as LoggingSettingsNode; Assert.IsNotNull(settingsNode); distributions = hierarchy.FindNodeByType(appNode, typeof(DistributionStrategyCollectionNode)) as DistributionStrategyCollectionNode; Assert.IsNotNull(distributions); // expect 2, inproc & custom Assert.AreEqual(2, distributions.Nodes.Count); }
public void RuntimeTest() { GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); ConfigurationContext builder = GeneratedHierarchy.ConfigurationContext; if (builder.IsValidSection(DistributorSettings.SectionName)) { DistributorSettings distributorSettings = builder.GetConfiguration(DistributorSettings.SectionName) as DistributorSettings; if (distributorSettings != null) { DistributorSettingsNode distributorSettingsNode = new DistributorSettingsNode(distributorSettings); foreach (ConfigurationNode node in distributorSettingsNode.Nodes) { if (node is SinkCollectionNode) { SinkCollectionNode sinkCollectionNode = (SinkCollectionNode)node; Assert.AreEqual(4, sinkCollectionNode.SinkDataCollection.Count); } else if (node is FormatterCollectionNode) { FormatterCollectionNode formatterCollectionNode = (FormatterCollectionNode)node; Assert.AreEqual(4, formatterCollectionNode.FormatterDataCollection.Count); } else if (node is CategoryCollectionNode) { CategoryCollectionNode categoryCollectionNode = (CategoryCollectionNode)node; Assert.AreEqual(2, categoryCollectionNode.CategoryDataCollection.Count); } } MsmqDistributorServiceNode msmqNode = new MsmqDistributorServiceNode(distributorSettings.DistributorService); Assert.IsNotNull(msmqNode.MsmqPath); } else { Assert.Fail(String.Format("Can not load section: {0}", DistributorSettings.SectionName)); } } }
public void OpenAndSaveTest() { GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); ConfigurationNode rootNode = GeneratedHierarchy.FindNodeByType(typeof(DistributorSettingsNode)); Assert.IsNotNull(rootNode); Assert.AreEqual(typeof(DistributorSettingsNode), rootNode.GetType()); GeneratedHierarchy.Save(); ApplicationConfigurationNode node = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain()); IUIHierarchy hierarchy = CreateHierarchyAndAddToHierarchyService(node, CreateDefaultConfiguration()); HierarchyService.SelectedHierarchy = hierarchy; hierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); Assert.IsTrue(hierarchy.ConfigurationContext.IsValidSection(DistributorSettings.SectionName)); }
public void RuntimeTest() { GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); ConfigurationContext configurationContext = GeneratedHierarchy.ConfigurationContext; if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { LoggingSettings clientSettings = configurationContext.GetConfiguration(LoggingSettings.SectionName) as LoggingSettings; if (clientSettings != null) { ClientSettingsNode settingsNode = new ClientSettingsNode(clientSettings); Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, settingsNode.CategoryFilterSettings.CategoryFilterMode); Assert.AreEqual(false, settingsNode.LoggingEnabled); Assert.AreEqual(1, settingsNode.MinimumPriority); Assert.AreEqual(false, settingsNode.TracingEnabled); } } else { Assert.Fail(String.Format("Can not load section: {0}", LoggingSettings.SectionName)); } }