public void TraceListenerNameEqualsReferencedTraceListenerName() { string traceListenerName = "a traceListener"; TraceListenerReferenceNode traceListenerReference = new TraceListenerReferenceNode(); TraceListenerCollectionNode traceListenerCollection = new TraceListenerCollectionNode(); TraceListenerNode aTraceListener = new WmiTraceListenerNode(new WmiTraceListenerData(traceListenerName)); ApplicationNode.AddNode(traceListenerReference); ApplicationNode.AddNode(traceListenerCollection); traceListenerCollection.AddNode(aTraceListener); traceListenerReference.ReferencedTraceListener = aTraceListener; Assert.AreEqual(traceListenerName, traceListenerReference.Name); }
/// <summary> /// Adds the <see cref="LoggingSettingsNode"/> and adds the default nodes. /// </summary> /// <param name="node">The <see cref="LoggingSettingsNode"/> added.</param> protected override void ExecuteCore(ConfigurationNode node) { base.ExecuteCore(node); LoggingSettingsNode loggingNode = ChildNode as LoggingSettingsNode; if (loggingNode == null) return; TextFormatterNode defaultTextFormatterNode = new TextFormatterNode(); FormattedEventLogTraceListenerNode defaultTraceListenerNode = new FormattedEventLogTraceListenerNode(); CategoryTraceSourceNode generalCategoryNode = new CategoryTraceSourceNode(new TraceSourceData(Resources.TraceSourceCategoryGeneral, SourceLevels.All)); loggingNode.AddNode(new LogFilterCollectionNode()); CategoryTraceSourceCollectionNode categoryTraceSourcesNode = new CategoryTraceSourceCollectionNode(); TraceListenerReferenceNode generalCategoryListenerRef = new TraceListenerReferenceNode(new TraceListenerReferenceData(defaultTraceListenerNode.Name)); categoryTraceSourcesNode.AddNode(generalCategoryNode); generalCategoryNode.AddNode(generalCategoryListenerRef); generalCategoryListenerRef.ReferencedTraceListener = defaultTraceListenerNode; loggingNode.AddNode(categoryTraceSourcesNode); SpecialTraceSourcesNode specialTraceSourcesNode = new SpecialTraceSourcesNode(); ErrorsTraceSourceNode errorsTraceSourcesNode = new ErrorsTraceSourceNode(new TraceSourceData()); TraceListenerReferenceNode errorsTraceListenerReferenceNode = new TraceListenerReferenceNode(); errorsTraceSourcesNode.AddNode(errorsTraceListenerReferenceNode); errorsTraceListenerReferenceNode.ReferencedTraceListener = defaultTraceListenerNode; specialTraceSourcesNode.AddNode(errorsTraceSourcesNode); specialTraceSourcesNode.AddNode(new NotProcessedTraceSourceNode(new TraceSourceData())); specialTraceSourcesNode.AddNode(new AllTraceSourceNode(new TraceSourceData())); loggingNode.AddNode(specialTraceSourcesNode); TraceListenerCollectionNode traceListenerCollectionNode = new TraceListenerCollectionNode(); traceListenerCollectionNode.AddNode(defaultTraceListenerNode); defaultTraceListenerNode.Formatter = defaultTextFormatterNode; loggingNode.AddNode(traceListenerCollectionNode); FormatterCollectionNode formattersNode = new FormatterCollectionNode(); formattersNode.AddNode(defaultTextFormatterNode); loggingNode.AddNode(formattersNode); loggingNode.DefaultCategory = generalCategoryNode; loggingNode.LogWarningWhenNoCategoriesMatch = true; loggingNode.TracingEnabled = true; ServiceHelper.GetUIService(serviceProvider).RefreshPropertyGrid(); }