Class KnownTypeRegistration
Describes custom behavior for a known type handled specially by Mocker. Registrations can supply direct instances, managed instances, mock configuration, and post-creation defaults.
Inherited Members
Namespace: FastMoq
Assembly: FastMoq.Core.dll
Syntax
public sealed class KnownTypeRegistration
Constructors
KnownTypeRegistration(Type)
Initializes a new registration for the supplied service type.
Declaration
public KnownTypeRegistration(Type serviceType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | serviceType |
Properties
ApplyObjectDefaults
Optional callback to apply post-creation defaults to resolved objects.
Declaration
public Action<Mocker, object>? ApplyObjectDefaults { get; init; }
Property Value
| Type | Description |
|---|---|
| Action<Mocker, object> |
ConfigureMock
Optional callback to configure a provider mock after it has been created. Use NativeMock when provider-specific behavior is required.
Declaration
public Action<Mocker, Type, IFastMock>? ConfigureMock { get; init; }
Property Value
| Type | Description |
|---|---|
| Action<Mocker, Type, IFastMock> |
DirectInstanceFactory
Optional factory for direct instance resolution in GetObject(Type, Action<object?>?).
Return null to indicate that the registration did not resolve the requested type.
Declaration
public Func<Mocker, Type, object?>? DirectInstanceFactory { get; init; }
Property Value
| Type | Description |
|---|---|
| Func<Mocker, Type, object> |
IncludeDerivedTypes
When true, the registration also applies to types assignable to ServiceType.
Declaration
public bool IncludeDerivedTypes { get; init; }
Property Value
| Type | Description |
|---|---|
| bool |
ManagedInstanceFactory
Optional factory for managed instance resolution during CreateInstance<T>(params object?[]).
Return null to indicate that the registration did not resolve the requested type.
Declaration
public Func<Mocker, Type, object?>? ManagedInstanceFactory { get; init; }
Property Value
| Type | Description |
|---|---|
| Func<Mocker, Type, object> |
ServiceType
Gets the service type this registration applies to.
Declaration
public Type ServiceType { get; }
Property Value
| Type | Description |
|---|---|
| Type |