DotnetStandardStreams/source/DotnetStreamsTests/Testables/TestableConsoleOutputTarget.cs
2025-05-15 13:27:49 -06:00

25 lines
543 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using DotnetStreams;
namespace DotnetStreamsTests.Testables
{
public class TestableConsoleOutputTarget : ConsoleOutputTarget, IDisposable
{
private readonly TextWriter previousOutWriter;
public TestableConsoleOutputTarget(TextWriter outWriter) : base()
{
previousOutWriter = System.Console.Out;
System.Console.SetOut(outWriter);
}
public void Dispose()
{
System.Console.SetOut(previousOutWriter);
}
}
}