static public void CaptureToTest(ITestOutputHelper output, Action handler) { var oldOut = Console.Out; var oldErr = Console.Error; var writer = new TestOutputWrite(output); Console.SetOut(writer); Console.SetError(writer); try { handler(); } finally { Console.SetError(oldErr); Console.SetOut(oldOut); } }
static public void CaptureToTest(this ITestOutputHelper output, Action handler) { TestOutputWrite.CaptureToTest(output, handler); }