Class AbstractAcceptanceTest
A class that can be used as a basis for running acceptance tests with Function Monkey at the command dispatch level designed for use with test frameworks that take a constructor approach to
One of the advantages of the pattern used by Function Monkey is that the host function triggers are separated cleanly from business logic and compiled with pre-tested templates allowing for comprehensive acceptance tests to be run just below this level which can often provide a high level of value with a lower level of complexity than also testing the Function triggers.
Typically the none-generic version of this class is more useful but this version allows for a custom IFunctionHostBuilder to be used if additional functionality is required over and above that baked into the supplied TestFunctionHostBuilder which solely handles command registration and dependency injection management.
Inheritance
Namespace: FunctionMonkey.Testing
Assembly: FunctionMonkey.Testing.dll
Syntax
public abstract class AbstractAcceptanceTest : object
Constructors
| Improve this Doc View SourceAbstractAcceptanceTest()
Declaration
protected AbstractAcceptanceTest()
Properties
| Improve this Doc View SourceDispatcher
Provides access to the command dispatcher registered in the service provider but wrapped in a decorator that implements validation.
Declaration
public ICommandDispatcher Dispatcher { get; }
Property Value
Type | Description |
---|---|
ICommand |
ServiceProvider
The constructed service provider
Declaration
public IServiceProvider ServiceProvider { get; }
Property Value
Type | Description |
---|---|
IService |
Methods
| Improve this Doc View SourceAddEnvironmentVariables(Stream, Boolean)
Set up environment variables based on a settings.json file in a stream
Declaration
protected void AddEnvironmentVariables(Stream appSettings, bool oneTimeOnly = true)
Parameters
Type | Name | Description |
---|---|---|
Stream | appSettings | |
System. |
oneTimeOnly |
AddEnvironmentVariables(String, Boolean)
Set up environment variables based on a settings.json filename
Declaration
protected void AddEnvironmentVariables(string appSettingsPath, bool oneTimeOnly = true)
Parameters
Type | Name | Description |
---|---|---|
System. |
appSettingsPath | |
System. |
oneTimeOnly |
BeforeServiceProviderBuild(IServiceCollection, ICommandRegistry)
This method can be used to modify dependency and command setup before the service provider has been built from the service collection.
This must not access members (and should not need to) as it is invoked from the constructor to support test frameworks such as XUnit that construct test cases this way.
Declaration
public virtual void BeforeServiceProviderBuild(IServiceCollection serviceCollection, ICommandRegistry commandRegistry)
Parameters
Type | Name | Description |
---|---|---|
IService |
serviceCollection | |
ICommand |
commandRegistry |
BeforeSetup()
Called during construction before setup is called (overriding methods cannot use member data)
Declaration
protected virtual void BeforeSetup()
ExecuteHttpAsync(ICommand, HttpMethod)
Runs a command through the IActionResult ASP.Net pathways and returns a HTTP response. This is useful for testing end to end HTTP triggered functions without having to actually host the function app. A method only needs specifying in the function supports multiple methods.
Declaration
public Task<HttpResponse> ExecuteHttpAsync(ICommand command, HttpMethod method = null)
Parameters
Type | Name | Description |
---|---|---|
ICommand | command | |
Http |
method |
Returns
Type | Description |
---|---|
Task<Http |
ExecuteHttpAsync<TResult>(ICommand<TResult>, HttpMethod)
Runs a command through the IActionResult ASP.Net pathways and returns a HTTP response. This is useful for testing end to end HTTP triggered functions without having to actually host the function app. A method only needs specifying in the function supports multiple methods.
Declaration
public Task<HttpResponse> ExecuteHttpAsync<TResult>(ICommand<TResult> command, HttpMethod method = null)
Parameters
Type | Name | Description |
---|---|---|
ICommand<TResult> | command | |
Http |
method |
Returns
Type | Description |
---|---|
Task<Http |
Type Parameters
Name | Description |
---|---|
TResult |