public void CanReadAndWriteInstrumentationConfiguration() { manager.Register(ServiceProvider); Assert.AreEqual(0, ErrorLogService.ValidationErrorCount); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); ApplicationNode.AddNode(new InstrumentationNode(new InstrumentationConfigurationSection(true, true, false))); manager.Save(ServiceProvider); Assert.AreEqual(0, ErrorLogService.ValidationErrorCount); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); ApplicationNode.ClearChildNodes(); manager.Open(ServiceProvider); Assert.AreEqual(0, ErrorLogService.ValidationErrorCount); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); InstrumentationNode node = (InstrumentationNode)ApplicationNode.Nodes[0]; Assert.IsNotNull(node); Assert.IsTrue(node.EventLoggingEnabled); Assert.IsTrue(node.PerformanceCountersEnabled); Assert.IsFalse(node.WmiEnabled); ApplicationNode.ClearChildNodes(); manager.Save(ServiceProvider); Assert.AreEqual(0, ErrorLogService.ValidationErrorCount); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); }
public void SerializationUtilityDeserializesToNullOnFailure() { string relativePathToInstrumentationNode = "/non extisting path"; InstrumentationNode deserializedInstance = SerializationUtility.DeserializeFromString(relativePathToInstrumentationNode, typeof(InstrumentationNode), ApplicationNode.Hierarchy) as InstrumentationNode; Assert.IsNull(deserializedInstance); }
public void ConstingWithSectionExposesCorrectValues() { InstrumentationConfigurationSection section = new InstrumentationConfigurationSection(true, true, true); InstrumentationNode node = new InstrumentationNode(section); Assert.IsTrue(node.PerformanceCountersEnabled); Assert.IsTrue(node.EventLoggingEnabled); Assert.IsTrue(node.WmiEnabled); }
public void ConstingWithSectionExposesCorrectValues() { InstrumentationConfigurationSection section = new InstrumentationConfigurationSection(true, true, true); InstrumentationNode node = new InstrumentationNode(section); Assert.IsTrue(node.PerformanceCountersEnabled); Assert.IsTrue(node.EventLoggingEnabled); Assert.IsTrue(node.WmiEnabled); }
public void CanSaveInstrumentationCofigurationInHierarch() { SaveInstrumentationSection(); InstrumentationNode instrumentationNode = (InstrumentationNode)Hierarchy.FindNodeByType(typeof(InstrumentationNode)); Assert.IsFalse(instrumentationNode.PerformanceCountersEnabled); Assert.IsFalse(instrumentationNode.WmiEnabled); Assert.IsTrue(instrumentationNode.EventLoggingEnabled); }
public void SavesMergedConfiguration() { File.SetAttributes(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, FileAttributes.Normal); ApplicationNode.Hierarchy.Load(); Assert.AreEqual(0, ServiceHelper.GetErrorService(ServiceProvider).ConfigurationErrorCount); ApplicationNode.Hierarchy.Open(); Assert.AreEqual(0, ServiceHelper.GetErrorService(ServiceProvider).ConfigurationErrorCount); InstrumentationNode instrumentationNode = (InstrumentationNode)ApplicationNode.Hierarchy.FindNodeByType(typeof(InstrumentationNode)); // test the settings from the original configuration file Assert.IsNotNull(instrumentationNode); Assert.IsTrue(instrumentationNode.EventLoggingEnabled); Assert.IsFalse(instrumentationNode.PerformanceCountersEnabled); Assert.IsTrue(instrumentationNode.WmiEnabled); // load the environment override ConfigurationNode overridesNode = ApplicationNode.Hierarchy.FindNodeByType(typeof(EnvironmentalOverridesNode)); Assert.IsNotNull(overridesNode); EnvironmentNode overrideNode = new EnvironmentNodeBuilder(ServiceProvider).Build("Environment.dconfig", overridesNode.Hierarchy); overridesNode.AddNode(overrideNode); // run the save merged environment command SaveMergedEnvironmentCommand command = new SaveMergedEnvironmentCommand(ServiceProvider); command.Execute(overrideNode); Assert.IsTrue(command.MergeSucceeded); // load the resulting configuration ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = Path.Combine( Path.GetDirectoryName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), overrideNode.EnvironmentConfigurationFile); System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); // get the instrumentation node InstrumentationConfigurationSection instrumentationSection = (InstrumentationConfigurationSection)configuration.GetSection(InstrumentationConfigurationSection.SectionName); // test the settings from the merged configuration file Assert.IsNotNull(instrumentationSection); Assert.IsFalse(instrumentationSection.EventLoggingEnabled); Assert.IsTrue(instrumentationSection.PerformanceCountersEnabled); Assert.IsTrue(instrumentationSection.WmiEnabled); }
public void SerializationUtilityCanSerializeConfigurationNode() { InstrumentationNode instrumentationNode = new InstrumentationNode(); ApplicationNode.AddNode(instrumentationNode); string serializedNode = SerializationUtility.SerializeToString(instrumentationNode, instrumentationNode.Hierarchy); string relativeNodePath = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, instrumentationNode.Hierarchy); Assert.AreEqual(relativeNodePath, serializedNode); }
public void SerializationUtilityCanDeserializeConfigurationNode() { InstrumentationNode instrumentationNode = new InstrumentationNode(); ApplicationNode.AddNode(instrumentationNode); string relativePathToInstrumentationNode = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, ApplicationNode.Hierarchy); Assert.IsNotNull(relativePathToInstrumentationNode); InstrumentationNode deserializedInstance = SerializationUtility.DeserializeFromString(relativePathToInstrumentationNode, typeof(InstrumentationNode), ApplicationNode.Hierarchy) as InstrumentationNode; Assert.AreEqual(instrumentationNode, deserializedInstance); }
public void CreateNodeTest() { Type t = typeof(InstrumentationNode); NodeCreationEntry entry = NodeCreationEntry.CreateNodeCreationEntryNoMultiples( new AddChildNodeCommand(ServiceProvider, t), t, typeof(InstrumentationConfigurationSection), "Instrumentation"); NodeCreationService.AddNodeCreationEntry(entry); InstrumentationNode node = NodeCreationService.CreateNodeByDataType( typeof(InstrumentationConfigurationSection)) as InstrumentationNode; Assert.IsNotNull(node); }
private void AddInstrumentationToHierarchy() { InstrumentationNode instrumentationNode = new InstrumentationNode(new InstrumentationConfigurationSection(false, true, false)); ApplicationNode.AddNode(instrumentationNode); }
private void AddInstrumentationToHierarchy() { InstrumentationNode instrumentationNode = new InstrumentationNode(new InstrumentationConfigurationSection(false, true, false)); ApplicationNode.AddNode(instrumentationNode); }