1 // ***********************************************************************
2 // Copyright (c) 2015 Charlie Poole
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
25 #define NUNIT_FRAMEWORK
29 using NUnit.Framework.TUnit;
33 namespace NUnit.Common
36 /// ExtendedTextWrapper wraps a TextWriter and makes it
37 /// look like an ExtendedTextWriter. All style indications
38 /// are ignored. It's used when text is being written
41 public class ExtendedTextWrapper : ExtendedTextWriter
43 private TextWriter _writer;
45 public ExtendedTextWrapper(TextWriter writer)
50 #region TextWriter Overrides
53 /// Write a single char value
55 public override void Write(char value)
61 /// Write a string value
63 public override void Write(string value)
69 /// Write a string value followed by a NewLine
71 public override void WriteLine(string value)
73 _writer.WriteLine(TLogger.DefaultTag + value);
77 /// Gets the encoding for this ExtendedTextWriter
79 public override Encoding Encoding
81 get { return _writer.Encoding; }
85 /// Dispose the Extended TextWriter
87 protected override void Dispose(bool disposing)
94 #region Extended Methods
97 /// Writes the value with the specified style.
99 /// <param name="style">The style.</param>
100 /// <param name="value">The value.</param>
101 public override void Write(ColorStyle style, string value)
107 /// Writes the value with the specified style
109 /// <param name="style">The style.</param>
110 /// <param name="value">The value.</param>
111 public override void WriteLine(ColorStyle style, string value)
117 /// Writes the label and the option that goes with it.
119 /// <param name="label">The label.</param>
120 /// <param name="option">The option.</param>
121 public override void WriteLabel(string label, object option)
124 Write(option.ToString());
128 /// Writes the label and the option that goes with it.
130 /// <param name="label">The label.</param>
131 /// <param name="option">The option.</param>
132 /// <param name="valueStyle">The color to display the value with</param>
133 public override void WriteLabel(string label, object option, ColorStyle valueStyle)
135 WriteLabel(label, option);
139 /// Writes the label and the option that goes with it followed by a new line.
141 /// <param name="label">The label.</param>
142 /// <param name="option">The option.</param>
143 public override void WriteLabelLine(string label, object option)
145 WriteLabel(label, option);
150 /// Writes the label and the option that goes with it followed by a new line.
152 /// <param name="label">The label.</param>
153 /// <param name="option">The option.</param>
154 /// <param name="valueStyle">The color to display the value with</param>
155 public override void WriteLabelLine(string label, object option, ColorStyle valueStyle)
157 WriteLabelLine(label, option);