title: Grabbing the output sent to Console.Out from within a unit test?
body: <p>I am building a unit test in C# with NUnit, and I'd like to test that the main program actually outputs the right output depending on the command line arguments.</p>
  
  <p>Is there a way from an NUnit test method that calls <code>Program.Main(...)</code> to grab everything written to <a href="https://docs.microsoft.com/en-us/dotnet/api/system.console.out" rel="noreferrer"><code>Console.Out</code></a> and <a href="https://docs.microsoft.com/en-us/dotnet/api/system.console.error" rel="noreferrer"><code>Console.Error</code></a> so that I can verify against it?</p>