Class FunctionScopedTest

Namespace
XBullet.EasyTesting.AzureFunctions
Assembly
XBullet.EasyTesting.AzureFunctions.dll

Provides a borrowed Functions host and an isolated scenario runner for test classes.

public abstract class FunctionScopedTest
Inheritance
FunctionScopedTest
Inherited Members
Extension Methods

Remarks

Independent of test frameworks. Each run creates and cleans up one fresh scenario.

Constructors

FunctionScopedTest(AzureFunctionTestHost, CancellationToken)

Creates a test base that borrows a host and test cancellation token.

protected FunctionScopedTest(AzureFunctionTestHost host, CancellationToken cancellationToken = default)

Parameters

host AzureFunctionTestHost

The non-null caller-owned function host, which this base never disposes.

cancellationToken CancellationToken

The token used by scope initialization and each test callback.

Properties

Host

Gets the borrowed function host.

protected AzureFunctionTestHost Host { get; }

Property Value

AzureFunctionTestHost

The caller-owned host supplied at construction.

TestCancellationToken

Gets the token used for every test run.

protected CancellationToken TestCancellationToken { get; }

Property Value

CancellationToken

The caller-supplied token, or a non-cancelable token when omitted.

Methods

RunAsync(Func<AzureFunctionTestScenarioScope, CancellationToken, Task>)

Runs a test in a fresh scenario with failure diagnostics and automatic cleanup.

protected Task RunAsync(Func<AzureFunctionTestScenarioScope, CancellationToken, Task> test)

Parameters

test Func<AzureFunctionTestScenarioScope, CancellationToken, Task>

The non-null callback borrowing the scope and test token.

Returns

Task

A task completing after the callback and cleanup finish.

RunAsync<TResult>(Func<AzureFunctionTestScenarioScope, CancellationToken, Task<TResult>>)

Runs a test function and returns detached data after cleanup.

protected Task<TResult> RunAsync<TResult>(Func<AzureFunctionTestScenarioScope, CancellationToken, Task<TResult>> test)

Parameters

test Func<AzureFunctionTestScenarioScope, CancellationToken, Task<TResult>>

The non-null callback borrowing the scope and test token.

Returns

Task<TResult>

The callback's result after cleanup finishes.

Type Parameters

TResult

The detached result type; do not return scenario-owned resources.