コード例 #1
0
        public void CanCreateInstanceWithNoFormatter()
        {
            var loggingSettings = new LoggingSettings();

            loggingSettings.TraceListeners.Add(
                new FormattedAppInsightsTraceListenerData(ConfigurationTestHelper.ListenerName, this.instrumentationKey));

            var listener = GetListener(ConfigurationTestHelper.ConditionalListenerName, ConfigurationTestHelper.SaveSectionsAndGetConfigurationSource(loggingSettings));

            Assert.IsNotNull(listener);
            Assert.AreEqual(listener.GetType(), typeof(FormattedAppInsightsTraceListener));
            Assert.IsNull(((FormattedAppInsightsTraceListener)listener).Formatter);
        }
コード例 #2
0
        public void CanCreateInstanceFromConfigurationFile()
        {
            var loggingSettings = new LoggingSettings();

            loggingSettings.Formatters.Add(new TextFormatterData("formatter", "some template"));
            loggingSettings.TraceListeners.Add(
                new FormattedAppInsightsTraceListenerData(ConfigurationTestHelper.ListenerName, this.instrumentationKey, "formatter"));

            var listener = GetListener(ConfigurationTestHelper.ConditionalListenerName, ConfigurationTestHelper.SaveSectionsAndGetConfigurationSource(loggingSettings));

            Assert.IsNotNull(listener);
            Assert.AreEqual(listener.GetType(), typeof(FormattedAppInsightsTraceListener));
            Assert.IsNotNull(((FormattedAppInsightsTraceListener)listener).Formatter);
            Assert.AreEqual(((FormattedAppInsightsTraceListener)listener).Formatter.GetType(), typeof(TextFormatter));
            Assert.AreEqual("some template", ((TextFormatter)((FormattedAppInsightsTraceListener)listener).Formatter).Template);
        }