public void ReconfigureDisposesUnusedListeners() { var traceListener = new MockDisposableTraceListener(); var config = new LoggingConfiguration(); config.AddLogSource("General", traceListener); var logWriter = new LogWriter(config); logWriter.Configure((cfg) => { cfg.LogSources.Clear(); cfg.AddLogSource("New", new DefaultTraceListener()); }); Assert.AreEqual(1, traceListener.DisposedCalls); }
public void ReconfigureDoesNotDisposeListenersStillUsedInSpecialSources() { var traceListener = new MockDisposableTraceListener(); var config = new LoggingConfiguration(); config.AddLogSource("General", traceListener); var logWriter = new LogWriter(config); logWriter.Configure((cfg) => { cfg.LogSources.Clear(); cfg.AddLogSource("New", new DefaultTraceListener()); cfg.SpecialSources.AllEvents.Listeners.Add(traceListener); }); Assert.AreEqual(0, traceListener.DisposedCalls); }
public void DisposingWriterDisposesAllTraceListenersOnce() { var traceListener = new MockDisposableTraceListener(); var config = new LoggingConfiguration(); config.AddLogSource("cat1", traceListener); config.AddLogSource("cat2", traceListener); config.SpecialSources.AllEvents.Listeners.Add(traceListener); var logWriter = new LogWriter(config); logWriter.Dispose(); Assert.AreEqual(1, traceListener.DisposedCalls); }