コード例 #1
0
 /// <summary>
 /// Resets this and the Debug class to its original settings.
 /// </summary>
 public static void Reset()
 {
     if (Listener != null)
     {
         Debug.Listeners.Remove(Listener);
         if (Debug.Listeners.Count > 0)
         {
             DefaultTraceListener defaultListener = Debug.Listeners[0] as DefaultTraceListener;
             if (defaultListener != null)
             {
                 defaultListener.AssertUiEnabled = OriginalAssertUiEnabled;
             }
         }
         Listener = null;
     }
 }
コード例 #2
0
 /// <summary>
 /// Initializes the Debug class with this trace listener and disables the Debug.Assert UI.
 /// </summary>
 /// <param name="context">the TestContext for the unit tests.</param>
 /// <param name="failOnDebugAssert">True to fail the test when hitting a Debug.Assert failure, false to continue the test.</param>
 public static void Initialize(TestContext context, bool failOnDebugAssert)
 {
     if (Listener == null)
     {
         Context           = context;
         FailOnDebugAssert = failOnDebugAssert;
         Listener          = new UnitTestTraceListener();
         if (Debug.Listeners.Count > 0)
         {
             DefaultTraceListener defaultListener = Debug.Listeners[0] as DefaultTraceListener;
             if (defaultListener != null)
             {
                 OriginalAssertUiEnabled         = defaultListener.AssertUiEnabled;
                 defaultListener.AssertUiEnabled = false;
             }
         }
         Debug.Listeners.Add(Listener);
     }
 }