Table of Contents

Class TestContext

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

Provide the context information of the current test. This is an adapter for the internal ExecutionContext class, hiding the internals from the user test.

public class TestContext
Inheritance
TestContext
Inherited Members

Constructors

TestContext(TestExecutionContext)

Construct a TestContext for an ExecutionContext

public TestContext(TestExecutionContext testExecutionContext)

Parameters

testExecutionContext TestExecutionContext

The ExecutionContext to adapt

Properties

CurrentContext

Get the current test context. This is created as needed. The user may save the context for use within a test, but it should not be used outside the test for which it is created.

public static TestContext CurrentContext { get; }

Property Value

TestContext

Out

Gets a TextWriter that will send output to the current test result.

public static TextWriter Out { get; }

Property Value

TextWriter

Random

Gets the random generator.

public RandomGenerator Random { get; }

Property Value

RandomGenerator

The random generator.

Result

Gets a Representation of the TestResult for the current test.

public TestContext.ResultAdapter Result { get; }

Property Value

TestContext.ResultAdapter

Test

Get a representation of the current test.

public TestContext.TestAdapter Test { get; }

Property Value

TestContext.TestAdapter

TestDirectory

Gets the directory containing the current test assembly.

public string TestDirectory { get; }

Property Value

string

WorkDirectory

Gets the directory to be used for outputing files created by this test run.

public string WorkDirectory { get; }

Property Value

string

Methods

Write(bool)

Write the string representation of a boolean value to the current result

public static void Write(bool value)

Parameters

value bool

Write(char)

Write a char to the current result

public static void Write(char value)

Parameters

value char

Write(char[])

Write a char array to the current result

public static void Write(char[] value)

Parameters

value char[]

Write(decimal)

Write the string representation of a decimal value to the current result

public static void Write(decimal value)

Parameters

value decimal

Write(double)

Write the string representation of a double to the current result

public static void Write(double value)

Parameters

value double

Write(int)

Write the string representation of an Int32 value to the current result

public static void Write(int value)

Parameters

value int

Write(long)

Write the string representation of an Int64 value to the current result

public static void Write(long value)

Parameters

value long

Write(object)

Write the string representation of an object to the current result

public static void Write(object value)

Parameters

value object

Write(float)

Write the string representation of a Single value to the current result

public static void Write(float value)

Parameters

value float

Write(string)

Write a string to the current result

public static void Write(string value)

Parameters

value string

Write(string, object)

Write a formatted string to the current result

public static void Write(string format, object arg1)

Parameters

format string
arg1 object

Write(string, object, object)

Write a formatted string to the current result

public static void Write(string format, object arg1, object arg2)

Parameters

format string
arg1 object
arg2 object

Write(string, object, object, object)

Write a formatted string to the current result

public static void Write(string format, object arg1, object arg2, object arg3)

Parameters

format string
arg1 object
arg2 object
arg3 object

Write(string, params object[])

Write a formatted string to the current result

public static void Write(string format, params object[] args)

Parameters

format string
args object[]

Write(uint)

Write the string representation of a UInt32 value to the current result

[CLSCompliant(false)]
public static void Write(uint value)

Parameters

value uint

Write(ulong)

Write the string representation of a UInt64 value to the current result

[CLSCompliant(false)]
public static void Write(ulong value)

Parameters

value ulong

WriteLine()

Write a line terminator to the current result

public static void WriteLine()

WriteLine(bool)

Write the string representation of a boolean value to the current result followed by a line terminator

public static void WriteLine(bool value)

Parameters

value bool

WriteLine(char)

Write a char to the current result followed by a line terminator

public static void WriteLine(char value)

Parameters

value char

WriteLine(char[])

Write a char array to the current result followed by a line terminator

public static void WriteLine(char[] value)

Parameters

value char[]

WriteLine(decimal)

Write the string representation of a decimal value to the current result followed by a line terminator

public static void WriteLine(decimal value)

Parameters

value decimal

WriteLine(double)

Write the string representation of a double to the current result followed by a line terminator

public static void WriteLine(double value)

Parameters

value double

WriteLine(int)

Write the string representation of an Int32 value to the current result followed by a line terminator

public static void WriteLine(int value)

Parameters

value int

WriteLine(long)

Write the string representation of an Int64 value to the current result followed by a line terminator

public static void WriteLine(long value)

Parameters

value long

WriteLine(object)

Write the string representation of an object to the current result followed by a line terminator

public static void WriteLine(object value)

Parameters

value object

WriteLine(float)

Write the string representation of a Single value to the current result followed by a line terminator

public static void WriteLine(float value)

Parameters

value float

WriteLine(string)

Write a string to the current result followed by a line terminator

public static void WriteLine(string value)

Parameters

value string

WriteLine(string, object)

Write a formatted string to the current result followed by a line terminator

public static void WriteLine(string format, object arg1)

Parameters

format string
arg1 object

WriteLine(string, object, object)

Write a formatted string to the current result followed by a line terminator

public static void WriteLine(string format, object arg1, object arg2)

Parameters

format string
arg1 object
arg2 object

WriteLine(string, object, object, object)

Write a formatted string to the current result followed by a line terminator

public static void WriteLine(string format, object arg1, object arg2, object arg3)

Parameters

format string
arg1 object
arg2 object
arg3 object

WriteLine(string, params object[])

Write a formatted string to the current result followed by a line terminator

public static void WriteLine(string format, params object[] args)

Parameters

format string
args object[]

WriteLine(uint)

Write the string representation of a UInt32 value to the current result followed by a line terminator

[CLSCompliant(false)]
public static void WriteLine(uint value)

Parameters

value uint

WriteLine(ulong)

Write the string representation of a UInt64 value to the current result followed by a line terminator

[CLSCompliant(false)]
public static void WriteLine(ulong value)

Parameters

value ulong