Class AzureFunctionTestHostBuilder
- Namespace
- XBullet.EasyTesting.AzureFunctions
- Assembly
- XBullet.EasyTesting.AzureFunctions.dll
Fluently builds a dependency-injection host for isolated-worker function tests.
public sealed class AzureFunctionTestHostBuilder
- Inheritance
-
AzureFunctionTestHostBuilder
- Inherited Members
Methods
AddFunction<TFunction>()
Adds a function class that can be resolved from the test host.
public AzureFunctionTestHostBuilder AddFunction<TFunction>() where TFunction : class
Returns
- AzureFunctionTestHostBuilder
This builder, for chaining.
Type Parameters
TFunctionThe reference-type function class registered with transient lifetime.
Build()
Creates the configured function test host.
public AzureFunctionTestHost Build()
Returns
- AzureFunctionTestHost
A new host that owns its service provider and must be disposed. Registered singleton and scoped disposable services are released with the host or invocation scope respectively.
ConfigureServices(Action<IServiceCollection>)
Configures dependencies used by function instances and invocation contexts.
public AzureFunctionTestHostBuilder ConfigureServices(Action<IServiceCollection> configure)
Parameters
configureAction<IServiceCollection>A non-null callback invoked synchronously once with the builder-owned mutable service collection. It may add, remove, or replace registrations but must not retain the collection.
Returns
- AzureFunctionTestHostBuilder
This builder, for chaining.
UseMiddleware(Func<FunctionContext, FunctionExecutionDelegate, Task>)
Adds inline middleware to the test invocation pipeline.
public AzureFunctionTestHostBuilder UseMiddleware(Func<FunctionContext, FunctionExecutionDelegate, Task> middleware)
Parameters
middlewareFunc<FunctionContext, FunctionExecutionDelegate, Task>A non-null asynchronous delegate retained by the host and invoked once per invocation in registration order. It may short-circuit by not invoking the supplied next delegate.
Returns
- AzureFunctionTestHostBuilder
This builder, for chaining.
UseMiddleware<TMiddleware>()
Adds isolated-worker middleware to the test invocation pipeline.
public AzureFunctionTestHostBuilder UseMiddleware<TMiddleware>() where TMiddleware : class, IFunctionsWorkerMiddleware
Returns
- AzureFunctionTestHostBuilder
This builder, for chaining. Middleware executes in registration order.
Type Parameters
TMiddlewareThe middleware class registered transiently and resolved once per invocation from its scope.