title: Testing Process.Start?
body: <p>I am creating an application that manages multiple instances of an external utility, supplying each with data and fetching results.</p>
  <p>But I'm facing a problem writing unit tests.</p>
  <p><strong>How to test if the target method actually starts a process (set via a property) when called?</strong></p>
  <p>I have tried:</p>
  <ul>
  <li>Make the class execute an external process and then use <code>GetProcessesByName()</code> to check if it has started.</li>
  <li>Use output redirection, e.g. using the greater-than sign to echo something to a file and test its existence</li>
  </ul>
  <p>I feel like creating yet another <code>.exe</code> to test it is overkill.</p>
  <p>Code:</p>
  <pre class="lang-cs prettyprint-override"><code>public void Start() 
  {
      if (!_isRunning) 
      {
          var startInfo = new ProcessStartInfo() {
            CreateNoWindow = true,
              UseShellExecute = true,
  
              FileName = _cmdLine,
              Arguments = _args
          };
  
          _process = Process.Start(startInfo);
          _isRunning = true;
      } 
      else 
      {
          throw new InvalidOperationException(&quot;Process already started&quot;);
      }
  }
  </code></pre>
  <p>I want to unit-test it so that a new process should start if nothing is running (<code>_isRunning == false</code>).</p>