Skip to content

Instantly share code, notes, and snippets.

@davidalpert
Created April 5, 2015 17:23
Show Gist options
  • Save davidalpert/9034704a78b18272b7ca to your computer and use it in GitHub Desktop.
Save davidalpert/9034704a78b18272b7ca to your computer and use it in GitHub Desktop.
An F# version of the RedirectedConsole
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