FastMoq
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    KnownTypeRegistration
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    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

    Extension Methods

    ObjectExtensions.RaiseIfNull<T>(T?, string?, string?, int?, string?)
    TestClassExtensions.GetFieldValue<TObject>(TObject, string, TObject?)
    TestClassExtensions.GetField<TObject>(TObject, string)
    TestClassExtensions.GetMemberName<T, TValue>(T, Expression<Func<T, TValue>>)
    TestClassExtensions.GetMember<T, TValue>(T, Expression<Func<T, TValue>>)
    TestClassExtensions.GetMethodValue<TObject>(TObject, string, object?, params object[])
    TestClassExtensions.GetMethod<TObject>(TObject, string)
    TestClassExtensions.GetPropertyValue<TObject>(TObject, string, object?)
    TestClassExtensions.GetProperty<TObject>(TObject, string)
    TestClassExtensions.SetFieldValue<TObject>(TObject, string, object?)
    TestClassExtensions.SetPropertyValue<TObject>(TObject, string, object?)
    MockerHttpMoqExtensions.SetupHttpMessage(object, Func<HttpResponseMessage>, Expression?, Expression?)
    MockerHttpMoqExtensions.SetupMessageAsync<TMock, TReturn>(object, Expression<Func<TMock, Task<TReturn>>>, Func<TReturn>)
    MockerHttpMoqExtensions.SetupMessageProtectedAsync<TMock, TReturn>(object, string, Func<TReturn>, params object?[]?)
    MockerHttpMoqExtensions.SetupMessageProtected<TMock, TReturn>(object, string, Func<TReturn>, params object?[]?)
    MockerHttpMoqExtensions.SetupMessage<TMock, TReturn>(object, Expression<Func<TMock, TReturn>>, Func<TReturn>)
    TestClassExtensions.GetFieldInfo<TType>(object, string)
    TestClassExtensions.GetFieldValue<T>(object?, FieldInfo)
    TestClassExtensions.GetFieldValue<T, TType>(object, string)
    In this article
    Back to top
    Generated 2026-04-08 12:38 UTC