FastMoq
Search Results for

    Show / Hide Table of Contents

    Class NSubstituteMockingProvider

    Provider implementation that adapts NSubstitute to the provider-neutral FastMoq abstractions.

    Inheritance
    object
    NSubstituteMockingProvider
    Implements
    IMockingProvider
    IMockingProviderCapabilities
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastMoq.Providers.NSubstituteProvider
    Assembly: FastMoq.Provider.NSubstitute.dll
    Syntax
    public sealed class NSubstituteMockingProvider : IMockingProvider, IMockingProviderCapabilities

    Fields

    Instance

    Gets the shared singleton instance of the NSubstitute provider.

    Declaration
    public static readonly NSubstituteMockingProvider Instance
    Field Value
    Type Description
    NSubstituteMockingProvider

    Properties

    Capabilities

    Gets the capability descriptor for this provider.

    Declaration
    public IMockingProviderCapabilities Capabilities { get; }
    Property Value
    Type Description
    IMockingProviderCapabilities

    SupportsCallBase

    Gets a value indicating whether NSubstitute supports base-call behavior.

    Declaration
    public bool SupportsCallBase { get; }
    Property Value
    Type Description
    bool

    SupportsInvocationTracking

    Gets a value indicating whether NSubstitute supports invocation tracking.

    Declaration
    public bool SupportsInvocationTracking { get; }
    Property Value
    Type Description
    bool

    SupportsLoggerCapture

    Gets a value indicating whether NSubstitute supports logger capture helpers.

    Declaration
    public bool SupportsLoggerCapture { get; }
    Property Value
    Type Description
    bool

    SupportsProtectedMembers

    Gets a value indicating whether NSubstitute supports protected member interception.

    Declaration
    public bool SupportsProtectedMembers { get; }
    Property Value
    Type Description
    bool

    SupportsSetupAllProperties

    Gets a value indicating whether NSubstitute supports automatic property backing.

    Declaration
    public bool SupportsSetupAllProperties { get; }
    Property Value
    Type Description
    bool

    Methods

    BuildExpression<T>()

    Builds a predicate expression suitable for provider-neutral matching.

    Declaration
    public Expression<Func<T, bool>> BuildExpression<T>()
    Returns
    Type Description
    Expression<Func<T, bool>>
    Type Parameters
    Name Description
    T

    ConfigureLogger(IFastMock, Action<LogLevel, EventId, string, Exception?>)

    Configures logger callback capture on the supplied mock.

    Declaration
    public void ConfigureLogger(IFastMock mock, Action<LogLevel, EventId, string, Exception?> callback)
    Parameters
    Type Name Description
    IFastMock mock
    Action<LogLevel, EventId, string, Exception> callback

    ConfigureProperties(IFastMock)

    Configures property behavior on the supplied mock when the provider supports it.

    Declaration
    public void ConfigureProperties(IFastMock mock)
    Parameters
    Type Name Description
    IFastMock mock

    CreateMock(Type, MockCreationOptions?)

    Creates an untyped FastMoq wrapper around a new NSubstitute substitute.

    Declaration
    public IFastMock CreateMock(Type type, MockCreationOptions? options = null)
    Parameters
    Type Name Description
    Type type
    MockCreationOptions options
    Returns
    Type Description
    IFastMock

    CreateMock<T>(MockCreationOptions?)

    Creates a typed FastMoq wrapper around a new NSubstitute substitute.

    Declaration
    public IFastMock<T> CreateMock<T>(MockCreationOptions? options = null) where T : class
    Parameters
    Type Name Description
    MockCreationOptions options
    Returns
    Type Description
    IFastMock<T>
    Type Parameters
    Name Description
    T

    SetCallBase(IFastMock, bool)

    Requests base-call behavior on the supplied mock.

    Declaration
    public void SetCallBase(IFastMock mock, bool value)
    Parameters
    Type Name Description
    IFastMock mock
    bool value

    SetupAllProperties(IFastMock)

    Requests property auto-configuration on the supplied mock.

    Declaration
    public void SetupAllProperties(IFastMock mock)
    Parameters
    Type Name Description
    IFastMock mock

    TryGetLegacy(IFastMock)

    Attempts to expose a provider-specific legacy mock object from a wrapper.

    Declaration
    public object? TryGetLegacy(IFastMock mock)
    Parameters
    Type Name Description
    IFastMock mock
    Returns
    Type Description
    object

    TryWrapLegacy(object, Type)

    Attempts to wrap a provider-specific legacy mock object in the FastMoq abstraction.

    Declaration
    public IFastMock? TryWrapLegacy(object legacyMock, Type mockedType)
    Parameters
    Type Name Description
    object legacyMock
    Type mockedType
    Returns
    Type Description
    IFastMock

    VerifyNoOtherCalls(IFastMock)

    Verifies that no unverified calls remain on the supplied mock.

    Declaration
    public void VerifyNoOtherCalls(IFastMock mock)
    Parameters
    Type Name Description
    IFastMock mock

    Verify<T>(IFastMock<T>, Expression<Action<T>>, TimesSpec?)

    Verifies that the supplied expression was invoked on the wrapped NSubstitute mock.

    Declaration
    public void Verify<T>(IFastMock<T> mock, Expression<Action<T>> expression, TimesSpec? times = null) where T : class
    Parameters
    Type Name Description
    IFastMock<T> mock
    Expression<Action<T>> expression
    TimesSpec? times
    Type Parameters
    Name Description
    T

    Implements

    IMockingProvider
    IMockingProviderCapabilities

    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