title: Unit test multi thread environment with breakpoints in Visual Studio 2008
body: <p>I am having a problem while debugging a unit test in Visual Studio 2008. The unit test uses a <code>System.Timers.Timer</code> (within the business logic) to handle a certain delay (1'000 miliseconds). The thread running the test is put to sleep for 5'000 miliseconds.</p>
  
  <p>When running the test on its own, it passes. When running all tests (>120) it sometimes passes and sometimes fails (<strong>not deterministic</strong>). I then tried setting a breakpoint in the mock object, where I set the flag that is asserted in the unit test. Now when I debug the test on its own, I get the phenomenon, that the <code>Assert.IsTrue()</code> fails but the Quick Watch tells me, that it is true:</p>
  
  <p><img src="https://i.stack.imgur.com/nc48f.png" alt="Assert.IsTrue(true) fails: why?"></p>
  
  <pre><code>public class ObjectManagerAccessMock : IObjectManagerAccess
  {
      public bool ExecuteCommandWasCalled { get; set; }
  
      public void ExecuteCommand()
      {
          ExecuteCommandWasCalled = true; //set breakpoint here
      }
  }
  </code></pre>
  
  <p>Does the thread running the test continue to run, when another thread is stopped (through the breakpoint)?</p>