Table of Contents

Class Test

Namespace
Codebelt.Extensions.Xunit
Assembly
Codebelt.Extensions.Xunit.dll

Represents the base class from which all implementations of unit testing should derive.

public abstract class Test : ITest, IDisposable, IAsyncDisposable, IAsyncLifetime
Inheritance
Test
Implements
IAsyncLifetime
Derived

Constructors

Test(ITestOutputHelper, Type)

Initializes a new instance of the Test class.

protected Test(ITestOutputHelper output = null, Type callerType = null)

Parameters

output ITestOutputHelper

An implementation of the Xunit.Abstractions.ITestOutputHelper interface.

callerType Type

The Type of caller that ends up invoking this instance.

Remarks

output is initialized automatically in an xUnit project.

Properties

CallerType

Gets the type of caller for this instance. Default is GetType().

public Type CallerType { get; }

Property Value

Type

The type of caller for this instance.

Disposed

Gets a value indicating whether this Test object is disposed.

public bool Disposed { get; }

Property Value

Boolean

true if this Test object is disposed; otherwise, false.

HasTestOutput

Gets a value indicating whether TestOutput has a reference to an implementation of Xunit.Abstractions.ITestOutputHelper.

protected bool HasTestOutput { get; }

Property Value

Boolean

true if this instance has a reference to an implementation of Xunit.Abstractions.ITestOutputHelper; otherwise, false.

TestOutput

Gets the console substitute to write out unit test information.

protected ITestOutputHelper TestOutput { get; }

Property Value

ITestOutputHelper

The console substitute to write out unit test information.

Methods

Dispose()

Releases all resources used by the Test object.

public void Dispose()

Dispose(Boolean)

Releases the unmanaged resources used by the Test object and optionally releases the managed resources.

protected void Dispose(bool disposing)

Parameters

disposing Boolean

true to release both managed and unmanaged resources; false to release only unmanaged resources.

DisposeAsync()

Asynchronously releases the resources used by the Test.

public async ValueTask DisposeAsync()

Returns

ValueTask

A ValueTask that represents the asynchronous dispose operation.

Remarks

InitializeAsync()

Called immediately after the class has been created, before it is used.

public virtual Task InitializeAsync()

Returns

Task

A Task that represents the asynchronous operation.

Match(String, String, Action<WildcardOptions>)

Provides a way, with wildcard support, to determine if actual matches expected.

public static bool Match(string expected, string actual, Action<WildcardOptions> setup = null)

Parameters

expected String

The expected string value.

actual String

The actual string value.

setup Action<WildcardOptions>

The WildcardOptions which may be configured.

Returns

Boolean

true if actual matches expected, false otherwise.

Remarks

Exceptions

ArgumentOutOfRangeException

expected cannot be matched with actual. Includes the non-matched string(s) in ActualValue.

OnDisposeManagedResources()

Called when this object is being disposed by either Dispose() or Dispose(Boolean) having disposing set to true and Disposed is false.

protected virtual void OnDisposeManagedResources()

OnDisposeManagedResourcesAsync()

Called when this object is being disposed by DisposeAsync().

protected virtual ValueTask OnDisposeManagedResourcesAsync()

Returns

ValueTask

OnDisposeUnmanagedResources()

Called when this object is being disposed by either Dispose() or Dispose(Boolean) and Disposed is false.

protected virtual void OnDisposeUnmanagedResources()

Explicit Interface Implementations

IAsyncLifetime.DisposeAsync()

Task IAsyncLifetime.DisposeAsync()

Returns

Task

See Also

ITestOutputHelper