public void AddChildNodesTest() { DistributorSettingsNode node = new DistributorSettingsNode(); applicationNode.Nodes.AddWithDefaultChildren(node); Assert.AreEqual(3, node.Nodes.Count); bool categories = false; bool formatters = false; bool sinks = false; foreach (ConfigurationNode configNode in node.Nodes) { if (configNode is CategoryCollectionNode) { categories = true; } else if (configNode is FormatterCollectionNode) { formatters = true; } else if (configNode is SinkCollectionNode) { sinks = true; } } Assert.IsTrue(categories && formatters && sinks); }
public void YouCanOnlyAddTheFormattersCollectionOnceToTheDistributorsSettingsNode() { DistributorSettingsNode distributorSettings = new DistributorSettingsNode(); applicationNode.Nodes.AddWithDefaultChildren(distributorSettings); distributorSettings.Nodes.Add(new FormatterCollectionNode()); }
public void DistributorSettingsPropertiesTest() { DistributorSettings settings = ConfigurationManager.GetConfiguration(DistributorSettings.SectionName) as DistributorSettings; DistributorSettingsNode settingsNode = new DistributorSettingsNode(settings); GeneratedApplicationNode.Nodes.Add(settingsNode); settingsNode.ResolveNodeReferences(); Assert.AreEqual(settings.DefaultCategory, settingsNode.DefaultCategory.Name); Assert.AreEqual(settings.DefaultFormatter, settingsNode.DefaultFormatter.Name); }
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 DistributorSettingsPropertiesTest() { CategoryData categoryData = new CategoryData(); categoryData.Name = SR.DefaultCategory; CategoryNode defaultCategory = new CategoryNode(categoryData); TextFormatterData formatterData = new TextFormatterData(); formatterData.Name = SR.DefaultFormatter; TextFormatterNode defaultFormatter = new TextFormatterNode(formatterData); DistributorSettingsNode distributorSettings = new DistributorSettingsNode(); applicationNode.Nodes.Add(distributorSettings); distributorSettings.DefaultFormatter = defaultFormatter; distributorSettings.DefaultCategory = defaultCategory; Assert.AreEqual(defaultCategory.Name, distributorSettings.DefaultCategory.Name); Assert.AreEqual(defaultFormatter, distributorSettings.DefaultFormatter); }