Created
April 5, 2015 17:23
-
-
Save davidalpert/9034704a78b18272b7ca to your computer and use it in GitHub Desktop.
An F# version of the RedirectedConsole
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TestHelpers | |
open System | |
open System.IO | |
type RedirectedConsole() = | |
let outBefore = Console.Out | |
let errorBefore = Console.Error | |
let console = new StringWriter() | |
do | |
Console.SetOut(console) | |
Console.SetError(console) | |
member this.Output = console.ToString() | |
member this.NormalizedOutput = this.Output.Replace("\r\n","\n") | |
interface IDisposable with | |
member this.Dispose() = | |
Console.SetOut(outBefore) | |
Console.SetError(errorBefore) | |
console.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment