private void enableLoggingToMemoryStream(string logSourceName, MemoryStream stream) { TraceSource source = TraceUtilities.GetSource(logSourceName); source.Switch.Level = SourceLevels.All; source.Listeners.Add(new TextWriterTraceListener(stream) { Filter = new EventTypeFilter(SourceLevels.All) }); }
public void Init() { memStream = new MemoryStream(); TextWriterTraceListener textListener = new TextWriterTraceListener(memStream); TraceSource traceSource = TraceUtilities.GetSource( TraceUtilities.DEPRECATION_MESSAGES_SOURCE); // Set the switch level to log all warnings. Setting this key is required // for the tests to pass, since this key usually comes from // App.config, but would be unset when running the test standalone since // Common lib doesn't have its own App.config. traceSource.Switch.Level = SourceLevels.All; traceSource.Listeners.Add(textListener); deprecatedMemberInfo = this.GetType().GetField("deprecatedField", BindingFlags.NonPublic | BindingFlags.Instance); nonDeprecatedMemberInfo = this.GetType().GetField("nonDeprecatedField", BindingFlags.NonPublic | BindingFlags.Instance); }