Class TestHost
- Namespace
- Mokkit.Suite
- Assembly
- Mokkit.dll
Represents a concrete implementation of Mokkit.Suite.ITestHost that provides dependency injection and service execution capabilities for test scenarios. This class manages the lifecycle of dependency container scopes and executes actions with resolved services from those containers.
public class TestHost : ITestHost, IDisposableInheritance
Derived
Implements
Inherited Members
Constructors
TestHost(IEnumerable<IDependencyContainer>, ITestHostBagAccessor, Guid)
Initializes a new instance of the Mokkit.Suite.TestHost class with the specified containers, bag accessor, and test host identifier. This constructor creates a new test host bag, establishes the test host context, and initializes the scope aggregator for dependency resolution.
protected TestHost(IEnumerable<IDependencyContainer> containers, ITestHostBagAccessor bagAccessor, Guid testHostId)Parameters
containersIEnumerable<IDependencyContainer>-
The collection of dependency containers to aggregate for service resolution.
bagAccessorITestHostBagAccessor-
The test host bag accessor for managing shared test resources.
testHostIdGuid-
The unique identifier for this test host instance.
Methods
Dispose()
public void Dispose()Execute<TService>(Action<TService>)
Executes an action with a single resolved service of type TService.
public void Execute<TService>(Action<TService> actionFn) where TService : classParameters
actionFnAction<TService>-
The action to execute with the resolved service.
Type Parameters
TService-
The type of service to resolve and pass to the action.
Execute<TService, TService2>(Action<TService, TService2>)
Executes an action with two resolved services of types TService and TService2.
public void Execute<TService, TService2>(Action<TService, TService2> actionFn) where TService : class where TService2 : classParameters
actionFnAction<TService, TService2>-
The action to execute with the resolved services.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
Execute<TService, TService2, TService3>(Action<TService, TService2, TService3>)
Executes an action with three resolved services of types TService, TService2, and TService3.
public void Execute<TService, TService2, TService3>(Action<TService, TService2, TService3> actionFn) where TService : class where TService2 : class where TService3 : classParameters
actionFnAction<TService, TService2, TService3>-
The action to execute with the resolved services.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
Execute<TService, TService2, TService3, TService4>(Action<TService, TService2, TService3, TService4>)
Executes an action with four resolved services of types TService, TService2, TService3, and TService4.
public void Execute<TService, TService2, TService3, TService4>(Action<TService, TService2, TService3, TService4> actionFn) where TService : class where TService2 : class where TService3 : class where TService4 : classParameters
actionFnAction<TService, TService2, TService3, TService4>-
The action to execute with the resolved services.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
TService4-
The type of the fourth service to resolve.
Execute<TService, TOutput>(Func<TService, TOutput>)
Executes a function with a single resolved service of type TService and returns the result.
public TOutput Execute<TService, TOutput>(Func<TService, TOutput> actionFn) where TService : classParameters
actionFnFunc<TService, TOutput>-
The function to execute with the resolved service.
Returns
- TOutput
-
The result of the function execution.
Type Parameters
TService-
The type of service to resolve and pass to the function.
TOutput-
The type of the result returned by the function.
Execute<TService, TService2, TOutput>(Func<TService, TService2, TOutput>)
Executes a function with two resolved services of types TService and TService2 and returns the result.
public TOutput Execute<TService, TService2, TOutput>(Func<TService, TService2, TOutput> actionFn) where TService : class where TService2 : classParameters
actionFnFunc<TService, TService2, TOutput>-
The function to execute with the resolved services.
Returns
- TOutput
-
The result of the function execution.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TOutput-
The type of the result returned by the function.
Execute<TService, TService2, TService3, TOutput>(Func<TService, TService2, TService3, TOutput>)
Executes a function with three resolved services of types TService, TService2, and TService3 and returns the result.
public TOutput Execute<TService, TService2, TService3, TOutput>(Func<TService, TService2, TService3, TOutput> actionFn) where TService : class where TService2 : class where TService3 : classParameters
actionFnFunc<TService, TService2, TService3, TOutput>-
The function to execute with the resolved services.
Returns
- TOutput
-
The result of the function execution.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
TOutput-
The type of the result returned by the function.
Execute<TService, TService2, TService3, TService4, TOutput>(Func<TService, TService2, TService3, TService4, TOutput>)
Executes a function with four resolved services of types TService, TService2, TService3, and TService4 and returns the result.
public TOutput Execute<TService, TService2, TService3, TService4, TOutput>(Func<TService, TService2, TService3, TService4, TOutput> actionFn) where TService : class where TService2 : class where TService3 : class where TService4 : classParameters
actionFnFunc<TService, TService2, TService3, TService4, TOutput>-
The function to execute with the resolved services.
Returns
- TOutput
-
The result of the function execution.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
TService4-
The type of the fourth service to resolve.
TOutput-
The type of the result returned by the function.
ExecuteAsync<TService>(Func<TService, Task>)
Executes an action with a single resolved service of type TService asynchronously.
public Task ExecuteAsync<TService>(Func<TService, Task> actionFn) where TService : classParameters
Returns
Type Parameters
TService-
The type of service to resolve and pass to the action.
ExecuteAsync<TService, TService2>(Func<TService, TService2, Task>)
Executes an action with two resolved services of types TService and TService2 asynchronously.
public Task ExecuteAsync<TService, TService2>(Func<TService, TService2, Task> actionFn) where TService : class where TService2 : classParameters
Returns
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
ExecuteAsync<TService, TService2, TService3>(Func<TService, TService2, TService3, Task>)
Executes an action with three resolved services of types TService, TService2, and TService3 asynchronously.
public Task ExecuteAsync<TService, TService2, TService3>(Func<TService, TService2, TService3, Task> actionFn) where TService : class where TService2 : class where TService3 : classParameters
actionFnFunc<TService, TService2, TService3, Task>-
The action to execute with the resolved services.
Returns
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
ExecuteAsync<TService, TService2, TService3, TService4>(Func<TService, TService2, TService3, TService4, Task>)
Executes an action with four resolved services of types TService, TService2, TService3, and TService4 asynchronously.
public Task ExecuteAsync<TService, TService2, TService3, TService4>(Func<TService, TService2, TService3, TService4, Task> actionFn) where TService : class where TService2 : class where TService3 : class where TService4 : classParameters
actionFnFunc<TService, TService2, TService3, TService4, Task>-
The action to execute with the resolved services.
Returns
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
TService4-
The type of the fourth service to resolve.
ExecuteAsync<TService, TOutput>(Func<TService, Task<TOutput>>)
Executes a function with a single resolved service of type TService and returns the result asynchronously.
public Task<TOutput> ExecuteAsync<TService, TOutput>(Func<TService, Task<TOutput>> actionFn) where TService : classParameters
Returns
- Task<TOutput>
-
The result of the function execution.
Type Parameters
TService-
The type of service to resolve and pass to the function.
TOutput-
The type of the result returned by the function.
ExecuteAsync<TService, TService2, TOutput>(Func<TService, TService2, Task<TOutput>>)
Executes a function with two resolved services of types TService and TService2 and returns the result asynchronously.
public Task<TOutput> ExecuteAsync<TService, TService2, TOutput>(Func<TService, TService2, Task<TOutput>> actionFn) where TService : class where TService2 : classParameters
actionFnFunc<TService, TService2, Task<TOutput>>-
The function to execute with the resolved services.
Returns
- Task<TOutput>
-
The result of the function execution.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TOutput-
The type of the result returned by the function.
ExecuteAsync<TService, TService2, TService3, TOutput>(Func<TService, TService2, TService3, Task<TOutput>>)
Executes a function with three resolved services of types TService, TService2, and TService3 and returns the result asynchronously.
public Task<TOutput> ExecuteAsync<TService, TService2, TService3, TOutput>(Func<TService, TService2, TService3, Task<TOutput>> actionFn) where TService : class where TService2 : class where TService3 : classParameters
actionFnFunc<TService, TService2, TService3, Task<TOutput>>-
The function to execute with the resolved services.
Returns
- Task<TOutput>
-
The result of the function execution.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
TOutput-
The type of the result returned by the function.
ExecuteAsync<TService, TService2, TService3, TService4, TOutput>(Func<TService, TService2, TService3, TService4, Task<TOutput>>)
Executes a function with four resolved services of types TService, TService2, TService3, and TService4 and returns the result asynchronously.
public Task<TOutput> ExecuteAsync<TService, TService2, TService3, TService4, TOutput>(Func<TService, TService2, TService3, TService4, Task<TOutput>> actionFn) where TService : class where TService2 : class where TService3 : class where TService4 : classParameters
actionFnFunc<TService, TService2, TService3, TService4, Task<TOutput>>-
The function to execute with the resolved services.
Returns
- Task<TOutput>
-
The result of the function execution.
Type Parameters
TService-
The type of the first service to resolve.
TService2-
The type of the second service to resolve.
TService3-
The type of the third service to resolve.
TService4-
The type of the fourth service to resolve.
TOutput-
The type of the result returned by the function.