21
21
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
// ***********************************************************************
24
using NUnit.Framework.Api;
26
namespace NUnit.Framework.Internal
33
/// EventListenerTextWriter is a TextWriter that channels output to
34
/// the TestOutput method of an ITestListener.
30
36
public class EventListenerTextWriter : TextWriter
32
38
private ITestListener eventListener;
33
39
private TestOutputType type;
42
/// Initializes a new instance of the <see cref="EventListenerTextWriter"/> class.
44
/// <param name="eventListener">The event listener.</param>
45
/// <param name="type">The type.</param>
35
46
public EventListenerTextWriter( ITestListener eventListener, TestOutputType type )
37
48
this.eventListener = eventListener;
53
/// Writes the specified char.
55
/// <param name="aChar">A char.</param>
40
56
override public void Write(char aChar)
42
58
this.eventListener.TestOutput( new TestOutput( aChar.ToString(), this.type ) );
62
/// Writes the specified string.
64
/// <param name="aString">A string.</param>
45
65
override public void Write(string aString)
47
67
this.eventListener.TestOutput( new TestOutput( aString, this.type ) );
71
/// Writes the specified string followed by a NewLine.
73
/// <param name="aString">A string.</param>
50
74
override public void WriteLine(string aString)
52
76
this.eventListener.TestOutput( new TestOutput( aString + this.NewLine, this.type ) );
80
/// When overridden in a derived class, returns the <see cref="T:System.Text.Encoding"/> in which the output is written.
84
/// The Encoding in which the output is written.
55
86
override public System.Text.Encoding Encoding
57
88
get { return Encoding.Default; }
64
95
//public class BufferedEventListenerTextWriter : TextWriter
66
// private ITestListener eventListener;
97
// private ITestListener listener;
67
98
// private TestOutputType type;
68
99
// private const int MAX_BUFFER = 1024;
69
100
// private StringBuilder sb = new StringBuilder( MAX_BUFFER );
71
// public BufferedEventListenerTextWriter( ITestListener eventListener, TestOutputType type )
102
// public BufferedEventListenerTextWriter( ITestListener listener, TestOutputType type )
73
// this.eventListener = eventListener;
104
// this.listener = listener;
74
105
// this.type = type;