<PackageReference Include="NUnit" Version="3.13.2" />

TestContext

public class TestContext
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 PropertyBagAdapter

PropertyBagAdapter adapts an IPropertyBag for consumption by the user.

public class ResultAdapter

ResultAdapter adapts a TestResult for consumption by the user test code.

public class TestAdapter

TestAdapter adapts a Test for consumption by the user test code.

public static TextWriter Error

Gets a TextWriter that will send output directly to Console.Error

public static readonly TestParameters Parameters

TestParameters object holds parameters for the test run, if any are specified

public static readonly TextWriter Progress

Gets a TextWriter for use in displaying immediate progress messages

public static TestContext CurrentContext { get; }

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 TextWriter Out { get; }

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

public int AssertCount { get; }

Gets the number of assertions executed up to this point in the test.

public int CurrentRepeatCount { get; }

Get the number of times the current Test has been repeated when using the RetryAttribute or RepeatAttribute.

public Randomizer Random { get; }

Gets the random generator.

public ResultAdapter Result { get; }

Gets a Representation of the TestResult for the current test.

public TestAdapter Test { get; }

Get a representation of the current test.

public string TestDirectory { get; }

Gets the directory containing the current test assembly.

public string WorkDirectory { get; }

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

public string WorkerId { get; }

Gets the unique name of the Worker that is executing this test.

public TestContext(TestExecutionContext testExecutionContext)

Construct a TestContext for an ExecutionContext

public static void AddFormatter(ValueFormatterFactory formatterFactory)

This method adds the a new ValueFormatterFactory to the chain of responsibility used for formatting values in messages. The scope of the change is the current TestContext.

public static void AddFormatter<TSupported>(ValueFormatter formatter)

This method provides a simplified way to add a ValueFormatter delegate to the chain of responsibility, creating the factory delegate internally. It is useful when the Type of the object is the only criterion for selection of the formatter, since it can be used without getting involved with a compound function.

public static void AddTestAttachment(string filePath, string description = null)

Attach a file to the current test result

public static void Write(bool value)

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

public static void Write(char value)

Write a char to the current result

public static void Write(char[] value)

Write a char array to the current result

public static void Write(double value)

Write the string representation of a double to the current result

public static void Write(int value)

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

public static void Write(long value)

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

public static void Write(decimal value)

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

public static void Write(object value)

Write the string representation of an object to the current result

public static void Write(float value)

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

public static void Write(string value)

Write a string to the current result

public static void Write(uint value)

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

public static void Write(ulong value)

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

public static void Write(string format, object arg1)

Write a formatted string to the current result

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

Write a formatted string to the current result

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

Write a formatted string to the current result

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

Write a formatted string to the current result

public static void WriteLine()

Write a line terminator to the current result

public static void WriteLine(bool value)

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

public static void WriteLine(char value)

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

public static void WriteLine(char[] value)

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

public static void WriteLine(double value)

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

public static void WriteLine(int value)

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

public static void WriteLine(long value)

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

public static void WriteLine(decimal value)

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

public static void WriteLine(object value)

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

public static void WriteLine(float value)

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

public static void WriteLine(string value)

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

public static void WriteLine(uint value)

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

public static void WriteLine(ulong value)

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

public static void WriteLine(string format, object arg1)

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

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

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)

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

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

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