Class TestOutputWriter
Wraps an Xunit.Abstractions.ITestOutputHelper with a TextWriter that can be used generate output in unit tests that will be included in the captured test log.
note
Only the Write(...) and WriteLine(...) methods are implemented.
Namespace: Neon.Xunit
Assembly: Neon.Xunit.dll
Syntax
public class TestOutputWriter : TextWriterRemarks
To use this class, you'll need to obtain a Xunit.Abstractions.ITestOutputHelper instance from Xunit via dependency injection by adding a parameter to your test constructor and then creating a TestOutputWriter from it, like:
public class MyTest : IClassFixture<AspNetFixture>
{
    private AspNetFixture               fixture;
    private TestAspNetFixtureClient     client;
    private TestOutputWriter            testWriter;
public Test_EndToEnd(AspNetFixture fixture, ITestOutputHelper outputHelper)
{
    this.fixture    = fixture;
    this.testWriter = new TestOutputWriter(outputHelper);
    fixture.Start<Startup>(logWriter: testWriter, logLevel: Neon.Diagnostics.LogLevel.Debug);
    client = new TestAspNetFixtureClient()
    {
        BaseAddress = fixture.BaseAddress
    };
 }
}
Constructors
TestOutputWriter(ITestOutputHelper)
Constructor.
Declaration
public TestOutputWriter(ITestOutputHelper outputHelper)Parameters
| Type | Name | Description | 
|---|---|---|
| ITestOutputHelper | outputHelper | The test output helper. | 
Exceptions
| Type | Condition | 
|---|---|
| NotImplementedException | Thrown for all methods except for  | 
Properties
Encoding
When overridden in a derived class, returns the character encoding in which the output is written.
Declaration
public override Encoding Encoding { get; }Property Value
| Type | Description | 
|---|---|
| Encoding | The character encoding in which the output is written. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| NotImplementedException | Thrown for all methods except for  | 
Methods
Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
Declaration
public override void Flush()Overrides
Exceptions
| Type | Condition | 
|---|---|
| NotImplementedException | Thrown for all methods except for  | 
FlushAsync()
Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
Declaration
public override Task FlushAsync()Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous flush operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The writer is currently in use by a previous write operation. | 
Write(bool)
Writes the text representation of a Boolean value to the text stream.
Declaration
public override void Write(bool value)Parameters
| Type | Name | Description | 
|---|---|---|
| bool | value | The  | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(char)
Writes a character to the text stream.
Declaration
public override void Write(char value)Parameters
| Type | Name | Description | 
|---|---|---|
| char | value | The character to write to the text stream. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(char[])
Writes a character array to the text stream.
Declaration
public override void Write(char[] buffer)Parameters
| Type | Name | Description | 
|---|---|---|
| char[] | buffer | The character array to write to the text stream. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(char[], int, int)
Writes a subarray of characters to the text stream.
Declaration
public override void Write(char[] buffer, int index, int count)Parameters
| Type | Name | Description | 
|---|---|---|
| char[] | buffer | The character array to write data from. | 
| int | index | The character position in the buffer at which to start retrieving data. | 
| int | count | The number of characters to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The buffer length minus  | 
| ArgumentNullException | The  | 
| ArgumentOutOfRangeException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(decimal)
Writes the text representation of a decimal value to the text stream.
Declaration
public override void Write(decimal value)Parameters
| Type | Name | Description | 
|---|---|---|
| decimal | value | The decimal value to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(double)
Writes the text representation of an 8-byte floating-point value to the text stream.
Declaration
public override void Write(double value)Parameters
| Type | Name | Description | 
|---|---|---|
| double | value | The 8-byte floating-point value to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(int)
Writes the text representation of a 4-byte signed integer to the text stream.
Declaration
public override void Write(int value)Parameters
| Type | Name | Description | 
|---|---|---|
| int | value | The 4-byte signed integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(long)
Writes the text representation of an 8-byte signed integer to the text stream.
Declaration
public override void Write(long value)Parameters
| Type | Name | Description | 
|---|---|---|
| long | value | The 8-byte signed integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(object)
Writes the text representation of an object to the text stream by calling the ToString method on that object.
Declaration
public override void Write(object value)Parameters
| Type | Name | Description | 
|---|---|---|
| object | value | The object to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(float)
Writes the text representation of a 4-byte floating-point value to the text stream.
Declaration
public override void Write(float value)Parameters
| Type | Name | Description | 
|---|---|---|
| float | value | The 4-byte floating-point value to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(string)
Writes a string to the text stream.
Declaration
public override void Write(string value)Parameters
| Type | Name | Description | 
|---|---|---|
| string | value | The string to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(string, object)
Writes a formatted string to the text stream, using the same semantics as the Format(string, object) method.
Declaration
public override void Write(string format, object arg0)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object | arg0 | The object to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is one). | 
Write(string, object, object)
Writes a formatted string to the text stream using the same semantics as the Format(string, object, object) method.
Declaration
public override void Write(string format, object arg0, object arg1)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object | arg0 | The first object to format and write. | 
| object | arg1 | The second object to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero) or greater than or equal to the number of objects to be formatted (which, for this method overload, is two). | 
Write(string, object, object, object)
Writes a formatted string to the text stream, using the same semantics as the Format(string, object, object, object) method.
Declaration
public override void Write(string format, object arg0, object arg1, object arg2)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object | arg0 | The first object to format and write. | 
| object | arg1 | The second object to format and write. | 
| object | arg2 | The third object to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is three). | 
Write(string, params object[])
Writes a formatted string to the text stream, using the same semantics as the Format(string, params object[]) method.
Declaration
public override void Write(string format, params object[] arg)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object[] | arg | An object array that contains zero or more objects to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the length of the  | 
Write(uint)
Writes the text representation of a 4-byte unsigned integer to the text stream.
Declaration
public override void Write(uint value)Parameters
| Type | Name | Description | 
|---|---|---|
| uint | value | The 4-byte unsigned integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
Write(ulong)
Writes the text representation of an 8-byte unsigned integer to the text stream.
Declaration
public override void Write(ulong value)Parameters
| Type | Name | Description | 
|---|---|---|
| ulong | value | The 8-byte unsigned integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteAsync(char)
Writes a character to the text stream asynchronously.
Declaration
public override Task WriteAsync(char value)Parameters
| Type | Name | Description | 
|---|---|---|
| char | value | The character to write to the text stream. | 
Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. | 
WriteAsync(char[], int, int)
Writes a subarray of characters to the text stream asynchronously.
Declaration
public override Task WriteAsync(char[] buffer, int index, int count)Parameters
| Type | Name | Description | 
|---|---|---|
| char[] | buffer | The character array to write data from. | 
| int | index | The character position in the buffer at which to start retrieving data. | 
| int | count | The number of characters to write. | 
Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ArgumentException | The  | 
| ArgumentOutOfRangeException | 
 | 
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. | 
WriteAsync(string)
Writes a string to the text stream asynchronously.
Declaration
public override Task WriteAsync(string value)Parameters
| Type | Name | Description | 
|---|---|---|
| string | value | The string to write. If  | 
Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. | 
WriteLine()
Writes a line terminator to the text stream.
Declaration
public override void WriteLine()Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(bool)
Writes the text representation of a Boolean value to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(bool value)Parameters
| Type | Name | Description | 
|---|---|---|
| bool | value | The  | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(char)
Writes a character to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(char value)Parameters
| Type | Name | Description | 
|---|---|---|
| char | value | The character to write to the text stream. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(char[])
Writes an array of characters to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(char[] buffer)Parameters
| Type | Name | Description | 
|---|---|---|
| char[] | buffer | The character array from which data is read. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(char[], int, int)
Writes a subarray of characters to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(char[] buffer, int index, int count)Parameters
| Type | Name | Description | 
|---|---|---|
| char[] | buffer | The character array from which data is read. | 
| int | index | The character position in  | 
| int | count | The maximum number of characters to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The buffer length minus  | 
| ArgumentNullException | The  | 
| ArgumentOutOfRangeException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(decimal)
Writes the text representation of a decimal value to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(decimal value)Parameters
| Type | Name | Description | 
|---|---|---|
| decimal | value | The decimal value to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(double)
Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(double value)Parameters
| Type | Name | Description | 
|---|---|---|
| double | value | The 8-byte floating-point value to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(int)
Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(int value)Parameters
| Type | Name | Description | 
|---|---|---|
| int | value | The 4-byte signed integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(long)
Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(long value)Parameters
| Type | Name | Description | 
|---|---|---|
| long | value | The 8-byte signed integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(object)
Writes the text representation of an object to the text stream, by calling the ToString method on that object, followed by a line terminator.
Declaration
public override void WriteLine(object value)Parameters
| Type | Name | Description | 
|---|---|---|
| object | value | The object to write. If  | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(float)
Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(float value)Parameters
| Type | Name | Description | 
|---|---|---|
| float | value | The 4-byte floating-point value to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(string)
Writes a string to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(string value)Parameters
| Type | Name | Description | 
|---|---|---|
| string | value | The string to write. If  | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(string, object)
Writes a formatted string and a new line to the text stream, using the same semantics as the Format(string, object) method.
Declaration
public override void WriteLine(string format, object arg0)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object | arg0 | The object to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is one). | 
WriteLine(string, object, object)
Writes a formatted string and a new line to the text stream, using the same semantics as the Format(string, object, object) method.
Declaration
public override void WriteLine(string format, object arg0, object arg1)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object | arg0 | The first object to format and write. | 
| object | arg1 | The second object to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is two). | 
WriteLine(string, object, object, object)
Writes out a formatted string and a new line to the text stream, using the same semantics as Format(string, object).
Declaration
public override void WriteLine(string format, object arg0, object arg1, object arg2)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object | arg0 | The first object to format and write. | 
| object | arg1 | The second object to format and write. | 
| object | arg2 | The third object to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is three). | 
WriteLine(string, params object[])
Writes out a formatted string and a new line to the text stream, using the same semantics as Format(string, object).
Declaration
public override void WriteLine(string format, params object[] arg)Parameters
| Type | Name | Description | 
|---|---|---|
| string | format | A composite format string. | 
| object[] | arg | An object array that contains zero or more objects to format and write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | A string or object is passed in as null. | 
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
| FormatException | 
 -or- The index of a format item is less than 0 (zero), or greater than or equal to the length of the  | 
WriteLine(uint)
Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(uint value)Parameters
| Type | Name | Description | 
|---|---|---|
| uint | value | The 4-byte unsigned integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLine(ulong)
Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator.
Declaration
public override void WriteLine(ulong value)Parameters
| Type | Name | Description | 
|---|---|---|
| ulong | value | The 8-byte unsigned integer to write. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The TextWriter is closed. | 
| IOException | An I/O error occurs. | 
WriteLineAsync()
Asynchronously writes a line terminator to the text stream.
Declaration
public override Task WriteLineAsync()Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. | 
WriteLineAsync(char)
Asynchronously writes a character to the text stream, followed by a line terminator.
Declaration
public override Task WriteLineAsync(char value)Parameters
| Type | Name | Description | 
|---|---|---|
| char | value | The character to write to the text stream. | 
Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. | 
WriteLineAsync(char[], int, int)
Asynchronously writes a subarray of characters to the text stream, followed by a line terminator.
Declaration
public override Task WriteLineAsync(char[] buffer, int index, int count)Parameters
| Type | Name | Description | 
|---|---|---|
| char[] | buffer | The character array to write data from. | 
| int | index | The character position in the buffer at which to start retrieving data. | 
| int | count | The number of characters to write. | 
Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
 | 
| ArgumentException | The  | 
| ArgumentOutOfRangeException | 
 | 
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. | 
WriteLineAsync(string)
Asynchronously writes a string to the text stream, followed by a line terminator.
Declaration
public override Task WriteLineAsync(string value)Parameters
| Type | Name | Description | 
|---|---|---|
| string | value | The string to write. If the value is null, only a line terminator is written. | 
Returns
| Type | Description | 
|---|---|
| Task | A task that represents the asynchronous write operation. | 
Overrides
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The text writer is disposed. | 
| InvalidOperationException | The text writer is currently in use by a previous write operation. |