public void SeverityLevelCanBeChangedForModule()
        {
            using (FileDiagnosticsTelemetryModule module = new FileDiagnosticsTelemetryModule())
            {
                module.LogFilePath = Directory.GetCurrentDirectory();
                module.LogFileName = Guid.NewGuid() + ".txt";

                using (TestEventSource eventSource = new TestEventSource())
                {
                    eventSource.TraceVerbose("MyVerbose1");
                    module.Severity = EventLevel.Verbose.ToString();

                    eventSource.TraceVerbose("MyVerbose2");

                    Assert.AreEqual(EventLevel.Verbose.ToString(), module.Severity);

                    string fileName = Path.Combine(module.LogFilePath, module.LogFileName);
                    Assert.IsTrue(File.Exists(fileName));
                    using (StreamReader sr = new StreamReader(fileName))
                    {
                        var content = sr.ReadToEnd();
                        Assert.IsTrue(content.Contains("MyVerbose2"), "Actual content: " + content);
                    }
                }
            }
        }
        public void TestCanChangeLogLevelAfterEventSourceCreated()
        {
            InMemoryTraceListener listener = new InMemoryTraceListener();

            using (TraceSourceForEventSource source = new TraceSourceForEventSource(SourceLevels.Error))
            {
                source.Listeners.Add(listener);

                using (TestEventSource eventSource = new TestEventSource())
                {
                    eventSource.TraceVerbose("MyVerbose");

                    source.LogLevel = EventLevel.Verbose;

                    eventSource.TraceVerbose("MyVerbose");

                    Assert.IsTrue(listener.Trace.Contains("MyVerbose"));
                    Assert.AreEqual(listener.Trace.IndexOf("MyVerbose"), listener.Trace.LastIndexOf("MyVerbose"));
                }
            }
        }
        public void TestVerboseMessageWillBeTraced()
        {
            InMemoryTraceListener listener = new InMemoryTraceListener();

            using (TraceSourceForEventSource source = new TraceSourceForEventSource(SourceLevels.Error))
            {
                source.LogLevel = EventLevel.Verbose;
                source.Listeners.Add(listener);

                using (TestEventSource eventSource = new TestEventSource())
                {
                    eventSource.TraceVerbose("MyVerbose");

                    Assert.IsTrue(listener.Trace.Contains("MyVerbose"), "Actual: " + listener.Trace);
                }
            }
        }