FastMoq
Search Results for

    Show / Hide Table of Contents

    Class InstanceFunction

    Stores a late-bound factory delegate that can create an instance of a specific runtime type.

    Inheritance
    object
    InstanceFunction
    InstanceFunction<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastMoq.Models
    Assembly: FastMoq.Core.dll
    Syntax
    public class InstanceFunction

    Constructors

    InstanceFunction(Type)

    Stores a late-bound factory delegate that can create an instance of a specific runtime type.

    Declaration
    public InstanceFunction(Type type)
    Parameters
    Type Name Description
    Type type

    The runtime type produced by the stored factory delegate.

    Properties

    Function

    Gets or sets the factory delegate used to create the instance.

    Declaration
    public Delegate? Function { get; set; }
    Property Value
    Type Description
    Delegate

    InstanceType

    Gets the runtime type that this factory produces.

    Declaration
    public Type InstanceType { get; }
    Property Value
    Type Description
    Type

    Methods

    CreateInstance(Type)

    Creates a new InstanceFunction placeholder for the specified runtime type.

    Declaration
    public static InstanceFunction CreateInstance(Type type)
    Parameters
    Type Name Description
    Type type

    The runtime type the instance function should describe.

    Returns
    Type Description
    InstanceFunction

    A new InstanceFunction for type.

    Invoke(Mocker, params object?[]?)

    Invokes the stored factory delegate with the supplied Mocker and optional parameter values.

    Declaration
    public object? Invoke(Mocker mocker, params object?[]? parameters)
    Parameters
    Type Name Description
    Mocker mocker

    The active mocker used as the first delegate argument.

    object[] parameters

    Optional extra parameters passed to delegates that accept a second argument.

    Returns
    Type Description
    object

    The created instance, or null when the stored delegate returns null.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when no compatible delegate has been assigned.

    SetFunction(Delegate)

    Assigns the factory delegate used to create the instance.

    Declaration
    public void SetFunction(Delegate function)
    Parameters
    Type Name Description
    Delegate function

    The delegate to store for later invocation.

    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-29 03:53 UTC