FastMoq
Search Results for

    Show / Hide Table of Contents

    Class OptionsTestExtensions

    Provides convenience helpers for registering IOptions<TOptions> dependencies in tests.

    Inheritance
    object
    OptionsTestExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastMoq.Extensions
    Assembly: FastMoq.Core.dll
    Syntax
    public static class OptionsTestExtensions

    Methods

    SetupOptions<T>(Mocker, bool)

    Registers a default IOptions<TOptions> value created from a new instance of T.

    Declaration
    public static Mocker SetupOptions<T>(this Mocker mocker, bool replace = false) where T : class, new()
    Parameters
    Type Name Description
    Mocker mocker

    The current Mocker instance.

    bool replace

    True to replace an existing options registration.

    Returns
    Type Description
    Mocker

    The current Mocker instance.

    Type Parameters
    Name Description
    T

    The options type to register.

    Examples
    var mocker = new Mocker()
        .SetupOptions<MyOptions>();

    SetupOptions<T>(Mocker, Func<T>, bool)

    Creates and registers a concrete IOptions<TOptions> value from a factory.

    Declaration
    public static Mocker SetupOptions<T>(this Mocker mocker, Func<T> create, bool replace = false) where T : class
    Parameters
    Type Name Description
    Mocker mocker

    The current Mocker instance.

    Func<T> create

    The factory used to create the options value each time IOptions<TOptions> is resolved.

    bool replace

    True to replace an existing options registration.

    Returns
    Type Description
    Mocker

    The current Mocker instance.

    Type Parameters
    Name Description
    T

    The options type to register.

    SetupOptions<T>(Mocker, T, bool)

    Registers a concrete IOptions<TOptions> value.

    Declaration
    public static Mocker SetupOptions<T>(this Mocker mocker, T value, bool replace = false) where T : class
    Parameters
    Type Name Description
    Mocker mocker

    The current Mocker instance.

    T value

    The options value to wrap in Create<TOptions>(TOptions).

    bool replace

    True to replace an existing options registration.

    Returns
    Type Description
    Mocker

    The current Mocker instance.

    Type Parameters
    Name Description
    T

    The options type to register.

    Examples
    var mocker = new Mocker()
        .SetupOptions(new CheckoutOptions { TimeoutSeconds = 30 });
    In this article
    Back to top
    Generated 2026-04-29 03:53 UTC