title: how to tell in code if we are running from a testmethod .net test
body: <p>Is there a way to know when code is being called from running a test method?</p>
  
  <pre><code>bool MyMethod()
  {
      if ( /* are we running a test? */ )
      {
          return true; // otherwise this will fail from the automated build script
      }
      else
      {
          // run the proper code
      } 
  }
  </code></pre>
  
  <p>and please spare me the "this is a really bad idea" comments :)</p>