Class TestFunctionContext

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

A minimal isolated-worker context with real dependency-injection services.

public sealed class TestFunctionContext : FunctionContext
Inheritance
TestFunctionContext
Inherited Members

Properties

BindingContext

Gets the binding context for the current function invocation. This context is used to retrieve binding data.

public override TestBindingContext BindingContext { get; }

Property Value

TestBindingContext

Bindings

Gets captured input and output bindings for this invocation.

public TestFunctionBindings Bindings { get; }

Property Value

TestFunctionBindings

The context-owned binding collection, mutable only through context and invocation operations.

CancellationToken

Gets the CancellationToken that signals a function invocation is being cancelled.

public override CancellationToken CancellationToken { get; }

Property Value

CancellationToken

Features

Gets a collection containing the features supported by this context.

public override IInvocationFeatures Features { get; }

Property Value

IInvocationFeatures

FunctionDefinition

Gets the FunctionDefinition that describes the function being executed.

public override TestFunctionDefinition FunctionDefinition { get; }

Property Value

TestFunctionDefinition

FunctionId

Gets the function ID, typically assigned by the host. This identifier is unique to a function and stable across invocations.

public override string FunctionId { get; }

Property Value

string

FunctionName

Gets the friendly function name assigned by the test.

public string FunctionName { get; }

Property Value

string

The non-empty name also used as this context's function identifier.

InstanceServices

Gets or sets the IServiceProvider that provides access to this execution's services.

public override IServiceProvider InstanceServices { get; set; }

Property Value

IServiceProvider

InvocationId

Gets the invocation ID. This identifier is unique to an invocation.

public override string InvocationId { get; }

Property Value

string

Items

Gets or sets a key/value collection that can be used to share data within the scope of this invocation.

public override IDictionary<object, object> Items { get; set; }

Property Value

IDictionary<object, object>

RetryContext

Gets the retry context containing information about retry activity for the event that triggered the current function invocation.

public override RetryContext RetryContext { get; }

Property Value

RetryContext

TestRetryContext

Gets the strongly typed test retry context.

public TestRetryContext TestRetryContext { get; }

Property Value

TestRetryContext

The current retry values, initially zero and replaced by WithRetry(int, int).

TestTraceContext

Gets the strongly typed test trace context.

public TestTraceContext TestTraceContext { get; }

Property Value

TestTraceContext

The current mutable test trace values, replaced when WithTrace(string, string) is called.

TraceContext

Gets the distributed tracing context.

public override TraceContext TraceContext { get; }

Property Value

TraceContext

Methods

WithBindingData(string, object)

Adds a value to binding data and returns this context.

public TestFunctionContext WithBindingData(string name, object value)

Parameters

name string

The non-empty binding-data key. Existing keys are replaced case-insensitively.

value object

The non-null value to retain without cloning.

Returns

TestFunctionContext

This context, for chaining.

WithFeature<T>(T)

Adds a typed invocation feature and returns this context.

public TestFunctionContext WithFeature<T>(T feature)

Parameters

feature T

The non-null feature instance retained by the invocation feature collection.

Returns

TestFunctionContext

This context, for chaining.

Type Parameters

T

The feature's registration and lookup type.

WithInputBinding(string, object?, string)

Adds an input value and its function-definition metadata.

public TestFunctionContext WithInputBinding(string name, object? value, string bindingType = "input")

Parameters

name string

The non-empty binding name. Existing captured values are replaced case-insensitively.

value object

The value to retain without cloning, or null to capture a null input without adding it to binding data.

bindingType string

The non-empty worker binding type. The default is input.

Returns

TestFunctionContext

This context, for chaining.

WithItem(object, object)

Adds an invocation item and returns this context.

public TestFunctionContext WithItem(object key, object value)

Parameters

key object

The non-null item key. An equal existing key is replaced.

value object

The non-null value retained without cloning.

Returns

TestFunctionContext

This context, for chaining.

WithOutputBinding(string, object?, string)

Adds an output value and its function-definition metadata.

public TestFunctionContext WithOutputBinding(string name, object? value, string bindingType = "output")

Parameters

name string

The non-empty binding name. Existing captured values are replaced case-insensitively.

value object

The output value to retain without cloning; null is accepted.

bindingType string

The non-empty worker binding type. The default is output.

Returns

TestFunctionContext

This context, for chaining.

WithRetry(int, int)

Sets retry state and returns this context.

public TestFunctionContext WithRetry(int retryCount, int maxRetryCount)

Parameters

retryCount int

The non-negative zero-based current retry count.

maxRetryCount int

The non-negative maximum retry count, greater than or equal to retryCount.

Returns

TestFunctionContext

This context, for chaining, with a newly allocated retry context.

WithTrace(string, string)

Sets distributed-tracing values and returns this context.

public TestFunctionContext WithTrace(string traceParent, string traceState = "")

Parameters

traceParent string

The non-null W3C trace-parent text. Format validation is left to tested code.

traceState string

The non-null trace-state text. The default is an empty string.

Returns

TestFunctionContext

This context, for chaining, with a newly allocated trace context.