Class MockingProviderRegistry
Global registry for available mocking providers with support for scoped overrides.
Inheritance
MockingProviderRegistry
Assembly: FastMoq.Core.dll
Syntax
public static class MockingProviderRegistry
Properties
Default
Declaration
public static IMockingProvider Default { get; }
Property Value
DiscoveryMode
Gets or sets how automatic provider discovery should behave for the current process.
Set this before resolving providers when a test process must avoid loading referenced assemblies or disable convention-based discovery.
Declaration
public static MockingProviderDiscoveryMode DiscoveryMode { get; set; }
Property Value
DiscoveryWarnings
Gets discovery warnings collected while scanning assemblies for convention-based provider registrations.
Declaration
public static IReadOnlyCollection<string> DiscoveryWarnings { get; }
Property Value
RegisteredProviderNames
Gets the registered provider names ordered alphabetically.
Declaration
public static IReadOnlyCollection<string> RegisteredProviderNames { get; }
Property Value
RegisteredProviders
Gets metadata for the currently registered providers ordered alphabetically by registration name.
Declaration
public static IReadOnlyCollection<MockingProviderRegistrationInfo> RegisteredProviders { get; }
Property Value
Methods
Clear()
Clears all provider registrations and resets both the global and scoped provider selections.
Declaration
public static void Clear()
Push(IMockingProvider)
Pushes a provider for the current async context and returns a disposable that restores the previous provider when disposed.
Declaration
public static IDisposable Push(IMockingProvider provider)
Parameters
| Type |
Name |
Description |
| IMockingProvider |
provider |
The provider to make active for the current async flow.
|
Returns
| Type |
Description |
| IDisposable |
A disposable scope that restores the prior provider when disposed.
|
Push(string)
Pushes a named provider for the current async context and returns a disposable that restores the previous provider when disposed.
Declaration
public static IDisposable Push(string name)
Parameters
| Type |
Name |
Description |
| string |
name |
The registered provider name to activate for the current async flow.
|
Returns
| Type |
Description |
| IDisposable |
A disposable scope that restores the prior provider when disposed.
|
Register(string, IMockingProvider, bool)
Registers a mocking provider under the supplied name.
Declaration
public static void Register(string name, IMockingProvider provider, bool setAsDefault = false)
Parameters
| Type |
Name |
Description |
| string |
name |
The provider name used to look up the registration later.
|
| IMockingProvider |
provider |
The provider implementation to register.
|
| bool |
setAsDefault |
When true, also makes the provider the global default provider.
|
SetDefault(string)
Sets the global default provider by name.
Declaration
public static void SetDefault(string name)
Parameters
| Type |
Name |
Description |
| string |
name |
The name of the provider to make the global default.
|
TryGet(string, out IMockingProvider)
Attempts to resolve a registered provider by name.
Declaration
public static bool TryGet(string name, out IMockingProvider provider)
Parameters
| Type |
Name |
Description |
| string |
name |
The provider name to look up.
|
| IMockingProvider |
provider |
When this method returns true, contains the resolved provider.
|
Returns
| Type |
Description |
| bool |
true when the provider was found or loaded; otherwise, false.
|
VerifyAnyArgs<T>(IFastMock<T>, string, TimesSpec?, params Type[])
Verifies calls to the named method on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyAnyArgs<T>(IFastMock<T> mock, string methodName, TimesSpec? times = null, params Type[] parameterTypes) where T : class
Parameters
Type Parameters
VerifyAnyArgs<T, TDelegate>(IFastMock<T>, Func<T, TDelegate>, TimesSpec?)
Verifies calls to the selected method on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyAnyArgs<T, TDelegate>(IFastMock<T> mock, Func<T, TDelegate> methodSelector, TimesSpec? times = null) where T : class where TDelegate : Delegate
Parameters
Type Parameters
| Name |
Description |
| T |
|
| TDelegate |
|
VerifyCalledAtLeastAnyArgs<T>(IFastMock<T>, string, int, params Type[])
Verifies that the named method was called at least the supplied number of times on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledAtLeastAnyArgs<T>(IFastMock<T> mock, string methodName, int times, params Type[] parameterTypes) where T : class
Parameters
Type Parameters
VerifyCalledAtLeastAnyArgs<T, TDelegate>(IFastMock<T>, Func<T, TDelegate>, int)
Verifies that the selected method was called at least the supplied number of times on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledAtLeastAnyArgs<T, TDelegate>(IFastMock<T> mock, Func<T, TDelegate> methodSelector, int times) where T : class where TDelegate : Delegate
Parameters
| Type |
Name |
Description |
| IFastMock<T> |
mock |
|
| Func<T, TDelegate> |
methodSelector |
|
| int |
times |
|
Type Parameters
| Name |
Description |
| T |
|
| TDelegate |
|
VerifyCalledAtLeast<T>(IFastMock<T>, Expression<Action<T>>, int)
Verifies that the specified invocation occurred at least the supplied number of times on a detached provider-first mock handle.
Declaration
public static void VerifyCalledAtLeast<T>(IFastMock<T> mock, Expression<Action<T>> expression, int times) where T : class
Parameters
Type Parameters
VerifyCalledAtMostAnyArgs<T>(IFastMock<T>, string, int, params Type[])
Verifies that the named method was called at most the supplied number of times on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledAtMostAnyArgs<T>(IFastMock<T> mock, string methodName, int times, params Type[] parameterTypes) where T : class
Parameters
Type Parameters
VerifyCalledAtMostAnyArgs<T, TDelegate>(IFastMock<T>, Func<T, TDelegate>, int)
Verifies that the selected method was called at most the supplied number of times on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledAtMostAnyArgs<T, TDelegate>(IFastMock<T> mock, Func<T, TDelegate> methodSelector, int times) where T : class where TDelegate : Delegate
Parameters
| Type |
Name |
Description |
| IFastMock<T> |
mock |
|
| Func<T, TDelegate> |
methodSelector |
|
| int |
times |
|
Type Parameters
| Name |
Description |
| T |
|
| TDelegate |
|
VerifyCalledAtMost<T>(IFastMock<T>, Expression<Action<T>>, int)
Verifies that the specified invocation occurred at most the supplied number of times on a detached provider-first mock handle.
Declaration
public static void VerifyCalledAtMost<T>(IFastMock<T> mock, Expression<Action<T>> expression, int times) where T : class
Parameters
Type Parameters
VerifyCalledExactlyAnyArgs<T>(IFastMock<T>, string, int, params Type[])
Verifies that the named method was called exactly the supplied number of times on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledExactlyAnyArgs<T>(IFastMock<T> mock, string methodName, int times, params Type[] parameterTypes) where T : class
Parameters
Type Parameters
VerifyCalledExactlyAnyArgs<T, TDelegate>(IFastMock<T>, Func<T, TDelegate>, int)
Verifies that the selected method was called exactly the supplied number of times on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledExactlyAnyArgs<T, TDelegate>(IFastMock<T> mock, Func<T, TDelegate> methodSelector, int times) where T : class where TDelegate : Delegate
Parameters
| Type |
Name |
Description |
| IFastMock<T> |
mock |
|
| Func<T, TDelegate> |
methodSelector |
|
| int |
times |
|
Type Parameters
| Name |
Description |
| T |
|
| TDelegate |
|
VerifyCalledExactly<T>(IFastMock<T>, Expression<Action<T>>, int)
Verifies that the specified invocation occurred exactly the supplied number of times on a detached provider-first mock handle.
Declaration
public static void VerifyCalledExactly<T>(IFastMock<T> mock, Expression<Action<T>> expression, int times) where T : class
Parameters
Type Parameters
VerifyCalledOnceAnyArgs<T>(IFastMock<T>, string, params Type[])
Verifies that the named method was called exactly once on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledOnceAnyArgs<T>(IFastMock<T> mock, string methodName, params Type[] parameterTypes) where T : class
Parameters
Type Parameters
VerifyCalledOnceAnyArgs<T, TDelegate>(IFastMock<T>, Func<T, TDelegate>)
Verifies that the selected method was called exactly once on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyCalledOnceAnyArgs<T, TDelegate>(IFastMock<T> mock, Func<T, TDelegate> methodSelector) where T : class where TDelegate : Delegate
Parameters
| Type |
Name |
Description |
| IFastMock<T> |
mock |
|
| Func<T, TDelegate> |
methodSelector |
|
Type Parameters
| Name |
Description |
| T |
|
| TDelegate |
|
VerifyCalledOnce<T>(IFastMock<T>, Expression<Action<T>>)
Verifies that the specified invocation occurred exactly once on a detached provider-first mock handle.
Declaration
public static void VerifyCalledOnce<T>(IFastMock<T> mock, Expression<Action<T>> expression) where T : class
Parameters
Type Parameters
VerifyNoOtherCalls(IFastMock)
Verifies that no other invocations were recorded on a detached provider-first mock handle.
Declaration
public static void VerifyNoOtherCalls(IFastMock mock)
Parameters
VerifyNotCalledAnyArgs<T>(IFastMock<T>, string, params Type[])
Verifies that the named method was never called on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyNotCalledAnyArgs<T>(IFastMock<T> mock, string methodName, params Type[] parameterTypes) where T : class
Parameters
Type Parameters
VerifyNotCalledAnyArgs<T, TDelegate>(IFastMock<T>, Func<T, TDelegate>)
Verifies that the selected method was never called on a detached provider-first mock handle while treating every argument as a wildcard matcher.
Declaration
public static void VerifyNotCalledAnyArgs<T, TDelegate>(IFastMock<T> mock, Func<T, TDelegate> methodSelector) where T : class where TDelegate : Delegate
Parameters
| Type |
Name |
Description |
| IFastMock<T> |
mock |
|
| Func<T, TDelegate> |
methodSelector |
|
Type Parameters
| Name |
Description |
| T |
|
| TDelegate |
|
VerifyNotCalled<T>(IFastMock<T>, Expression<Action<T>>)
Verifies that the specified invocation never occurred on a detached provider-first mock handle.
Declaration
public static void VerifyNotCalled<T>(IFastMock<T> mock, Expression<Action<T>> expression) where T : class
Parameters
Type Parameters
WrapLegacy(object, Type)
Wraps a legacy provider-specific mock object in the provider-agnostic IFastMock abstraction.
Declaration
public static IFastMock WrapLegacy(object legacyMock, Type mockedType)
Parameters
| Type |
Name |
Description |
| object |
legacyMock |
The legacy provider-specific mock object to wrap.
|
| Type |
mockedType |
The mocked type represented by legacyMock.
|
Returns
| Type |
Description |
| IFastMock |
A provider-agnostic wrapper for the legacy mock object.
|
Exceptions
| Type |
Condition |
| NotSupportedException |
Thrown when no registered provider can adapt the supplied legacy mock.
|