Table of Contents

Class TestingContext

Namespace
Microsoft.Accordant
Assembly
Accordant.Operations.dll

Testing context that provides access to the system under test during test execution. Provides common functionality for all testing contexts.

public sealed class TestingContext
Inheritance
TestingContext
Inherited Members

Constructors

TestingContext(ISpec, string)

public TestingContext(ISpec spec, string testDirectoryPath = null)

Parameters

spec ISpec
testDirectoryPath string

Properties

RequestPrinter

public Func<object, string> RequestPrinter { get; set; }

Property Value

Func<object, string>

ResponsePrinter

public Func<object, string> ResponsePrinter { get; set; }

Property Value

Func<object, string>

Spec

The spec being tested.

public ISpec Spec { get; set; }

Property Value

ISpec

Methods

Get<T>()

Gets the registered service of the specified type. Use this in ExecuteAsync(TestingContext, TRequest) to access the system under test or other registered services.

public T Get<T>()

Returns

T

The registered service instance.

Type Parameters

T

The type of the service to retrieve.

Exceptions

InvalidOperationException

Thrown if no service of type T has been registered.

Register<T>(T)

Registers a target instance that can be retrieved via Get<T>(). This is typically called during test initialization to register the system under test.

public void Register<T>(T instance)

Parameters

instance T

The target instance to register.

Type Parameters

T

The type of the target.

Target<T>()

Gets the registered target of the specified type. This is an alias for Get<T>() for backwards compatibility.

[Obsolete("Use Get<T>() instead. This method will be removed in a future version.")]
public T Target<T>()

Returns

T

The registered target instance.

Type Parameters

T

The type of the target to retrieve.