Class FunctionContextTestExtensions
Provides Azure Functions worker helpers for typed InstanceServices setup and execution-context shaping.
Inherited Members
Namespace: FastMoq.AzureFunctions.Extensions
Assembly: FastMoq.AzureFunctions.dll
Syntax
public static class FunctionContextTestExtensions
Methods
AddFunctionContextInstanceServices(Mocker, Action<IServiceCollection>?, bool, bool)
Builds and registers typed InstanceServices behavior for the current Mocker instance.
Declaration
public static Mocker AddFunctionContextInstanceServices(this Mocker mocker, Action<IServiceCollection>? configureServices = null, bool replace = false, bool includeWorkerDefaults = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Mocker | mocker | The current Mocker instance. |
| Action<IServiceCollection> | configureServices | Optional service registrations to apply after the worker defaults. |
| bool | replace | True to replace an existing known-type registration. |
| bool | includeWorkerDefaults | True to include logging, options, and WorkerOptions setup. |
Returns
| Type | Description |
|---|---|
| Mocker | The current Mocker instance. |
AddFunctionContextInstanceServices(Mocker, IServiceProvider, bool)
Registers typed InstanceServices behavior for the current Mocker instance.
Declaration
public static Mocker AddFunctionContextInstanceServices(this Mocker mocker, IServiceProvider instanceServices, bool replace = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Mocker | mocker | The current Mocker instance. |
| IServiceProvider | instanceServices | The provider to expose through InstanceServices. |
| bool | replace | True to replace an existing IServiceProvider registration and overwrite previously configured instance-services helper values while preserving other FunctionContext behavior. |
Returns
| Type | Description |
|---|---|
| Mocker | The current Mocker instance. |
AddFunctionContextInstanceServices(IFastMock, IServiceProvider)
Configures typed InstanceServices behavior on a tracked FunctionContext mock without replacing the enclosing Mocker service registrations.
Declaration
public static IFastMock AddFunctionContextInstanceServices(this IFastMock fastMock, IServiceProvider instanceServices)
Parameters
| Type | Name | Description |
|---|---|---|
| IFastMock | fastMock | The tracked mock whose InstanceServices getter should return |
| IServiceProvider | instanceServices | The provider to expose through InstanceServices. |
Returns
| Type | Description |
|---|---|
| IFastMock | The current tracked mock. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
AddFunctionContextInvocationId(Mocker, string, bool)
Registers a FunctionContext invocation identifier for the current Mocker instance.
Declaration
public static Mocker AddFunctionContextInvocationId(this Mocker mocker, string invocationId, bool replace = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Mocker | mocker | The current Mocker instance. |
| string | invocationId | The invocation identifier to expose through InvocationId. |
| bool | replace | True to overwrite a previously configured invocation-identifier helper value while preserving other FunctionContext behavior. |
Returns
| Type | Description |
|---|---|
| Mocker | The current Mocker instance. |
Remarks
This helper configures mock-backed FunctionContext instances. Concrete contexts with their own immutable execution metadata may ignore this registration.
AddFunctionContextInvocationId(IFastMock, string)
Configures a tracked FunctionContext mock to return the supplied invocation identifier.
Declaration
public static IFastMock AddFunctionContextInvocationId(this IFastMock fastMock, string invocationId)
Parameters
| Type | Name | Description |
|---|---|---|
| IFastMock | fastMock | The tracked mock whose InvocationId getter should return |
| string | invocationId | The invocation identifier to expose through InvocationId. |
Returns
| Type | Description |
|---|---|
| IFastMock | The current tracked mock. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
CreateFunctionContextInstanceServices(Mocker, Action<IServiceCollection>?, bool)
Creates a typed InstanceServices provider with the common Azure Functions worker defaults.
Declaration
public static IServiceProvider CreateFunctionContextInstanceServices(this Mocker mocker, Action<IServiceCollection>? configureServices = null, bool includeWorkerDefaults = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Mocker | mocker | The current Mocker instance. |
| Action<IServiceCollection> | configureServices | Optional service registrations to apply after the worker defaults. |
| bool | includeWorkerDefaults | True to include logging, options, and WorkerOptions setup. |
Returns
| Type | Description |
|---|---|
| IServiceProvider | A typed IServiceProvider suitable for InstanceServices. |