Class IFastMockNSubstituteExtensions
NSubstitute-specific convenience extensions for IFastMock<T>.
These stay in the provider package so the core abstractions remain provider agnostic.
Prefer provider-first members such as Instance, Reset(), and FastMoq verification helpers first, and use these extensions when the test intentionally needs NSubstitute-specific APIs.
Inheritance
IFastMockNSubstituteExtensions
Assembly: FastMoq.Provider.NSubstitute.dll
Syntax
public static class IFastMockNSubstituteExtensions
Methods
AsNSubstitute<T>(IFastMock<T>)
Returns the tracked substitute instance after validating that the active provider produced an NSubstitute substitute.
Use this when the test intentionally needs NSubstitute-specific APIs such as Received().
Declaration
public static T AsNSubstitute<T>(this IFastMock<T> fastMock) where T : class
Parameters
Returns
Type Parameters
Examples
Select the NSubstitute provider first, then use AsNSubstitute<T>(IFastMock<T>) as the provider-native escape hatch when the test truly needs NSubstitute semantics.
using var providerScope = MockingProviderRegistry.Push("nsubstitute");
var mocker = new Mocker();
var gateway = mocker.GetOrCreateMock<IOrderGateway>();
gateway.AsNSubstitute().Publish(42);
gateway.Received().Publish(42);
ClearReceivedCalls<T>(IFastMock<T>)
Clears recorded calls on the tracked substitute.
Declaration
public static void ClearReceivedCalls<T>(this IFastMock<T> fastMock) where T : class
Parameters
Type Parameters
DidNotReceiveWithAnyArgs<T>(IFastMock<T>)
NSubstitute convenience shortcut for fastMock.AsNSubstitute().DidNotReceiveWithAnyArgs().
Declaration
public static T DidNotReceiveWithAnyArgs<T>(this IFastMock<T> fastMock) where T : class
Parameters
Returns
Type Parameters
DidNotReceive<T>(IFastMock<T>)
NSubstitute convenience shortcut for fastMock.AsNSubstitute().DidNotReceive().
Declaration
public static T DidNotReceive<T>(this IFastMock<T> fastMock) where T : class
Parameters
Returns
Type Parameters
ReceivedWithAnyArgs<T>(IFastMock<T>)
NSubstitute convenience shortcut for fastMock.AsNSubstitute().ReceivedWithAnyArgs().
Declaration
public static T ReceivedWithAnyArgs<T>(this IFastMock<T> fastMock) where T : class
Parameters
Returns
Type Parameters
Received<T>(IFastMock<T>)
NSubstitute convenience shortcut for fastMock.AsNSubstitute().Received().
Declaration
public static T Received<T>(this IFastMock<T> fastMock) where T : class
Parameters
Returns
Type Parameters
Received<T>(IFastMock<T>, int)
NSubstitute convenience shortcut for fastMock.AsNSubstitute().Received(requiredNumberOfCalls).
Declaration
public static T Received<T>(this IFastMock<T> fastMock, int requiredNumberOfCalls) where T : class
Parameters
| Type |
Name |
Description |
| IFastMock<T> |
fastMock |
|
| int |
requiredNumberOfCalls |
|
Returns
Type Parameters