title: Best way to unit test console c# app
body: <p>I have a simple console app. It's fired of with a normal main and the entire program recides in main. It uses the <a href="http://commandline.codeplex.com/" rel="noreferrer">Command Line Parser Library</a>. Then I have a second project in the solution containing unit tests for the application. But I don't seem to find a good way to start processes of the main program from the tests. My current code for actually start the process looks something like this.</p>
  
  <pre><code>...
  
  process = new Process();
  process.StartInfo.FileName = "FooBar";
  process.StartInfo.Arguments = arguments;
  
  // use it to start from testing environment
  process.StartInfo.UseShellExecute = false;
  
  // redirect outputs to have it in testing console
  process.StartInfo.RedirectStandardOutput = true;
  process.StartInfo.RedirectStandardError = true;
  
  ...
  </code></pre>
  
  <p>I have tried setting</p>
  
  <pre><code>process.StartInfo.WorkingDirectory
  </code></pre>
  
  <p>to</p>
  
  <pre><code>AppDomain.CurrentDomain.BaseDirectory
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Environment.CurrentDirectory;
  </code></pre>
  
  <p>But do I have to specify the entire relative path for the console applications executable or is there a refined way of starting processes of the "tested" application?
  First I had my tests as a class in the "main" program and then it worked just fine. The issues started when I moved the tests to their own project. That's why I suspect a path being the issue or something of that nature.</p>
  
  <p>I also tried Running Program.Main but that just feels so wrong :)</p>