public void TraceWriter_ITextFormatter_NonExtensionCallPattern(Func <ILogger, string, TraceLevel> loggerAction)
        {
            string message = "Hello, World!";

            // Need to explicity define lowest level.
            LoggerConfiguration loggerConfiguration = new LoggerConfiguration().MinimumLevel.Verbose();

            InMemoryTraceWriter traceWriter = new InMemoryTraceWriter(TraceLevel.Verbose);

            ITextFormatter formatter = new MessageTemplateTextFormatter("{Message}", null);

            loggerConfiguration = TraceWriterLoggerConfigurationExtensions.TraceWriter(loggerConfiguration.WriteTo, traceWriter, formatter, LogEventLevel.Verbose);

            ILogger logger = loggerConfiguration.CreateLogger();

            Assert.Equal(0, traceWriter.Events.Count);

            TraceLevel expectedTraceLevel = loggerAction(logger, message);

            Assert.Equal(1, traceWriter.Events.Count);

            TraceEvent traceEvent = traceWriter.Events.First();

            Assert.Equal(message, traceEvent.Message);
            Assert.Equal(expectedTraceLevel, traceEvent.Level);
        }
        public void TraceWriter_IFormatProvider_NullTraceWriter()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                LoggerConfiguration loggerConfiguration = new LoggerConfiguration();

                TraceWriterLoggerConfigurationExtensions.TraceWriter(loggerConfiguration.WriteTo, null);
            });
        }
        public void TraceWriter_IFormatProvider_NullLoggerConfiguration()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                InMemoryTraceWriter traceWriter = new InMemoryTraceWriter(TraceLevel.Verbose);

                TraceWriterLoggerConfigurationExtensions.TraceWriter(null, traceWriter);
            });
        }
        public void TraceWriter_ITextFormatter_NullTraceWriter()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                LoggerConfiguration loggerConfiguration = new LoggerConfiguration();

                ITextFormatter formatter = new RawFormatter();

                TraceWriterLoggerConfigurationExtensions.TraceWriter(loggerConfiguration.WriteTo, null, formatter);
            });
        }
        public void TraceWriter_IFormatProvider_NullOutputTemplate()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                LoggerConfiguration loggerConfiguration = new LoggerConfiguration();

                InMemoryTraceWriter traceWriter = new InMemoryTraceWriter(TraceLevel.Verbose);

                string outputTemplate = null;

                TraceWriterLoggerConfigurationExtensions.TraceWriter(loggerConfiguration.WriteTo, traceWriter, outputTemplate);
            });
        }
        public void TraceWriter_ITextFormatter_NullFormatter()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                LoggerConfiguration loggerConfiguration = new LoggerConfiguration();

                InMemoryTraceWriter traceWriter = new InMemoryTraceWriter(TraceLevel.Verbose);

                ITextFormatter formatter = null;

                TraceWriterLoggerConfigurationExtensions.TraceWriter(loggerConfiguration.WriteTo, traceWriter, formatter);
            });
        }