Class Mocker
Core mock coordinator (provider-based creation integrated).
Assembly: FastMoq.Core.dll
Syntax
Examples
Use Mocker as the main test composition root when you want provider-first arrangement based on concrete registrations and policy-driven construction.
var fileSystem = new MockFileSystem();
fileSystem.AddFile(@"c:\orders\42.json", new MockFileData("{ \"id\": 42, \"total\": 125.50 }"));
var mocker = new Mocker()
.AddType<IFileSystem>(fileSystem);
var resolvedFileSystem = mocker.GetRequiredObject<IFileSystem>();
resolvedFileSystem.File.Exists(@"c:\orders\42.json").Should().BeTrue();
resolvedFileSystem.Should().BeSameAs(fileSystem);
Constructors
Mocker()
Initializes a new Mocker instance with a no-op external logging callback.
Declaration
Mocker(Action<LogLevel, EventId, string, Exception?>)
Initializes a new Mocker instance with an exception-aware logging callback.
Declaration
public Mocker(Action<LogLevel, EventId, string, Exception?> loggingCallback)
Parameters
Mocker(Action<LogLevel, EventId, string>)
Initializes a new Mocker instance with a three-parameter logging callback.
Declaration
public Mocker(Action<LogLevel, EventId, string> loggingCallback)
Parameters
Mocker(Dictionary<Type, IInstanceModel>)
Initializes a new Mocker instance with an existing type map.
Declaration
public Mocker(Dictionary<Type, IInstanceModel> map)
Parameters
Mocker(Dictionary<Type, IInstanceModel>, Action<LogLevel, EventId, string, Exception?>)
Initializes a new Mocker instance with an existing type map and an exception-aware logging callback.
Declaration
public Mocker(Dictionary<Type, IInstanceModel> map, Action<LogLevel, EventId, string, Exception?> loggingCallback)
Parameters
Mocker(Dictionary<Type, IInstanceModel>, Action<LogLevel, EventId, string>)
Initializes a new Mocker instance with an existing type map and a three-parameter logging callback.
Declaration
public Mocker(Dictionary<Type, IInstanceModel> map, Action<LogLevel, EventId, string> loggingCallback)
Parameters
Fields
creatingTypeList
Tracks types currently being created so recursive resolution can short-circuit circular member population.
Declaration
protected readonly List<Type> creatingTypeList
Field Value
fileSystem
The shared in-memory file system used by built-in file-system resolution helpers.
Declaration
public readonly MockFileSystem fileSystem
Field Value
| Type |
Description |
| MockFileSystem |
|
mockCollection
Stores the tracked mock models for this Mocker instance.
Declaration
protected readonly List<MockModel> mockCollection
Field Value
Properties
Behavior
Feature flag container controlling behavior such as base-call usage, dependency injection, nested member population, logging capture, and strict verification.
Declaration
public MockBehaviorOptions Behavior { get; set; }
Property Value
ConstructorHistory
Tracks constructor-selection history for created instances.
Declaration
public ConstructorHistory ConstructorHistory { get; }
Property Value
ExceptionLog
Captured exception messages observed during resolution and invocation helper flows.
Declaration
public ObservableExceptionLog ExceptionLog { get; }
Property Value
HttpClient
The shared HttpClient created for this mocker instance.
Declaration
public HttpClient HttpClient { get; }
Property Value
LogEntries
Captured log entries observed through this mocker instance.
Declaration
public ObservableLogEntries LogEntries { get; }
Property Value
LoggingCallback
Callback invoked when FastMoq captures a log entry through this mocker instance.
Declaration
public Action<LogLevel, EventId, string, Exception?> LoggingCallback { get; }
Property Value
OptionalParameterResolution
Controls how optional constructor and invocation parameters are resolved when values are not supplied explicitly.
Declaration
public OptionalParameterResolutionMode OptionalParameterResolution { get; set; }
Property Value
Policy
Policy settings that control built-in type resolution and constructor fallback behavior.
Declaration
public MockerPolicyOptions Policy { get; }
Property Value
Uri
The base URI associated with the shared HttpClient.
Declaration
Property Value
Methods
AddFileSystemAbstractionMapping()
Registers the standard System.IO.Abstractions mappings backed by the current mock file system.
Declaration
public void AddFileSystemAbstractionMapping()
AddInjections<T>(T, Type?)
Populates injectable fields and properties on the supplied object using the current resolution pipeline.
Declaration
public T AddInjections<T>(T obj, Type? referenceType = null) where T : class?
Parameters
| Type |
Name |
Description |
| T |
obj |
The object whose injectable members should be populated.
|
| Type |
referenceType |
Optional type used to discover injectable members instead of the runtime type.
|
Returns
| Type |
Description |
| T |
The same object instance after injection.
|
Type Parameters
| Name |
Description |
| T |
The object type to update.
|
AddKeyedType(Type, object, Type, Func<Mocker, object>?, bool, params object?[]?)
Adds a keyed type registration for this Mocker instance.
Declaration
public Mocker AddKeyedType(Type tInterface, object serviceKey, Type tClass, Func<Mocker, object>? createFunc = null, bool replace = false, params object?[]? args)
Parameters
Returns
AddKeyedType<T>(object, Func<Mocker, T>?, bool, params object?[]?)
Adds a keyed concrete registration with factory for this Mocker instance.
Declaration
public Mocker AddKeyedType<T>(object serviceKey, Func<Mocker, T>? createFunc = null, bool replace = false, params object?[]? args) where T : class
Parameters
Returns
Type Parameters
AddKeyedType<T>(object, T, bool)
Adds a keyed concrete value for this Mocker instance.
Declaration
public Mocker AddKeyedType<T>(object serviceKey, T value, bool replace = false)
Parameters
| Type |
Name |
Description |
| object |
serviceKey |
|
| T |
value |
|
| bool |
replace |
|
Returns
Type Parameters
AddKeyedType<TInterface, TClass>(object, bool, params object?[]?)
Adds a keyed interface-to-concrete registration for this Mocker instance.
Declaration
public Mocker AddKeyedType<TInterface, TClass>(object serviceKey, bool replace = false, params object?[]? args) where TInterface : class where TClass : class
Parameters
Returns
Type Parameters
| Name |
Description |
| TInterface |
|
| TClass |
|
AddKeyedType<TInterface, TClass>(object, Func<Mocker, TClass>?, bool, params object?[]?)
Adds a keyed interface-to-concrete registration with factory for this Mocker instance.
Declaration
public Mocker AddKeyedType<TInterface, TClass>(object serviceKey, Func<Mocker, TClass>? createFunc, bool replace = false, params object?[]? args) where TInterface : class where TClass : class
Parameters
Returns
Type Parameters
| Name |
Description |
| TInterface |
|
| TClass |
|
AddKnownType(KnownTypeRegistration, bool)
Adds a custom known-type registration for this Mocker instance.
This is the extensibility point for framework-like types that need special resolution or setup behavior.
Declaration
public Mocker AddKnownType(KnownTypeRegistration registration, bool replace = false)
Parameters
Returns
AddKnownType<TKnown>(Func<Mocker, Type, TKnown?>?, Func<Mocker, Type, TKnown?>?, Action<Mocker, Type, IFastMock>?, Action<Mocker, TKnown>?, bool, bool)
Adds a typed custom known-type registration for this Mocker instance.
Declaration
public Mocker AddKnownType<TKnown>(Func<Mocker, Type, TKnown?>? directInstanceFactory = null, Func<Mocker, Type, TKnown?>? managedInstanceFactory = null, Action<Mocker, Type, IFastMock>? configureMock = null, Action<Mocker, TKnown>? applyObjectDefaults = null, bool includeDerivedTypes = false, bool replace = false)
Parameters
Returns
Type Parameters
AddProperties(Type, object?, params KeyValuePair<string, object>[])
Populates readable properties on an object using either explicit values or resolved dependencies.
Declaration
public object? AddProperties(Type type, object? obj, params KeyValuePair<string, object>[] data)
Parameters
Returns
AddProperties<T>(T, params KeyValuePair<string, object>[])
Populates readable properties on an object using either explicit values or resolved dependencies.
Declaration
public T? AddProperties<T>(T obj, params KeyValuePair<string, object>[] data)
Parameters
Returns
Type Parameters
AddType(Type, Type, Func<Mocker, object>?, bool, params object?[]?)
Registers an interface-to-concrete mapping for object resolution.
Declaration
public Mocker AddType(Type tInterface, Type tClass, Func<Mocker, object>? createFunc = null, bool replace = false, params object?[]? args)
Parameters
| Type |
Name |
Description |
| Type |
tInterface |
The service or abstraction type to resolve.
|
| Type |
tClass |
The concrete implementation type to construct.
|
| Func<Mocker, object> |
createFunc |
Optional factory used instead of the default constructor path.
|
| bool |
replace |
True to replace an existing registration for the same service type.
|
| object[] |
args |
Optional constructor or factory arguments associated with the registration.
|
Returns
AddType<T>(Func<Mocker, T>?, bool, params object?[]?)
Registers a concrete type using an optional typed factory.
Declaration
public Mocker AddType<T>(Func<Mocker, T>? createFunc = null, bool replace = false, params object?[]? args) where T : class
Parameters
Returns
Type Parameters
AddType<T>(T, bool)
Registers a concrete instance so future object resolution returns that instance instead of auto-creating a mock.
Declaration
public Mocker AddType<T>(T value, bool replace = false)
Parameters
| Type |
Name |
Description |
| T |
value |
|
| bool |
replace |
|
Returns
Type Parameters
Examples
Use this overload when a dependency should be a known runtime object rather than a tracked mock.
var fileSystem = new MockFileSystem();
var mocker = new Mocker()
.AddType<IFileSystem>(fileSystem);
var resolvedFileSystem = mocker.GetRequiredObject<IFileSystem>();
resolvedFileSystem.Should().BeSameAs(fileSystem);
AddType<TInterface, TClass>(bool, params object?[]?)
Registers a type as its own implementation for future resolution.
Declaration
public Mocker AddType<TInterface, TClass>(bool replace = false, params object?[]? args) where TInterface : class where TClass : class
Parameters
Returns
Type Parameters
| Name |
Description |
| TInterface |
|
| TClass |
|
AddType<TInterface, TClass>(Func<Mocker, TClass>?, bool, params object?[]?)
Registers a type mapping that uses a typed factory during resolution.
Declaration
public Mocker AddType<TInterface, TClass>(Func<Mocker, TClass>? createFunc, bool replace = false, params object?[]? args) where TInterface : class where TClass : class
Parameters
Returns
Type Parameters
| Name |
Description |
| TInterface |
|
| TClass |
|
BuildExpression<T>()
Builds a wildcard predicate expression using the active mocking provider.
Declaration
public static Expression<Func<T, bool>> BuildExpression<T>()
Returns
Type Parameters
CallMethod(InvocationOptions?, Action, params object?[])
Invokes an action using the supplied invocation options.
Declaration
public void CallMethod(InvocationOptions? options, Action action, params object?[] args)
Parameters
CallMethod(InvocationOptions?, Delegate, params object?[])
Invokes a delegate without using its return value and with explicit invocation options.
Declaration
public void CallMethod(InvocationOptions? options, Delegate del, params object?[] args)
Parameters
CallMethod(Action, params object?[])
Invokes an action using the mocker's current invocation defaults.
Declaration
public void CallMethod(Action action, params object?[] args)
Parameters
CallMethod(Delegate, params object?[])
Invokes a delegate without using its return value.
Declaration
public void CallMethod(Delegate del, params object?[] args)
Parameters
CallMethodAsync<TReturn>(InvocationOptions?, Delegate, params object?[])
Invokes a delegate and awaits a task result using the supplied invocation options.
Declaration
public Task<TReturn> CallMethodAsync<TReturn>(InvocationOptions? options, Delegate del, params object?[] args)
Parameters
Returns
| Type |
Description |
| Task<TReturn> |
|
Type Parameters
CallMethodAsync<TReturn>(Delegate, params object?[])
Invokes a delegate and awaits a task result using the mocker's current invocation defaults.
Declaration
public Task<TReturn> CallMethodAsync<TReturn>(Delegate del, params object?[] args)
Parameters
Returns
| Type |
Description |
| Task<TReturn> |
|
Type Parameters
CallMethod<TReturn>(InvocationOptions?, Delegate, params object?[])
Invokes a delegate and returns its result using the supplied invocation options.
Declaration
public TReturn CallMethod<TReturn>(InvocationOptions? options, Delegate del, params object?[] args)
Parameters
Returns
Type Parameters
CallMethod<TReturn>(InvocationOptions?, Func<TReturn>, params object?[])
Invokes a function and returns its result using the supplied invocation options.
Declaration
public TReturn CallMethod<TReturn>(InvocationOptions? options, Func<TReturn> func, params object?[] args)
Parameters
Returns
Type Parameters
CallMethod<TReturn>(Delegate, params object?[])
Invokes a delegate and returns its result using the mocker's current invocation defaults.
Declaration
public TReturn CallMethod<TReturn>(Delegate del, params object?[] args)
Parameters
Returns
Type Parameters
CallMethod<TReturn>(Func<TReturn>, params object?[])
Invokes a function and returns its result using the mocker's current invocation defaults.
Declaration
public TReturn CallMethod<TReturn>(Func<TReturn> func, params object?[] args)
Parameters
| Type |
Name |
Description |
| Func<TReturn> |
func |
|
| object[] |
args |
|
Returns
Type Parameters
CreateFastMock<T>(MockCreationOptions?)
Creates a provider-first mock and registers it.
Declaration
public IFastMock<T> CreateFastMock<T>(MockCreationOptions? options = null) where T : class
Parameters
Returns
Type Parameters
CreateInstanceByType<T>(InstanceCreationFlags, params Type?[])
Creates an instance of T by selecting a constructor that matches the supplied parameter types and creation flags.
Declaration
public T? CreateInstanceByType<T>(InstanceCreationFlags flags, params Type?[] parameterTypes) where T : class
Parameters
Returns
Type Parameters
CreateInstanceByType<T>(params Type?[])
Creates an instance of T by selecting a constructor that matches the supplied parameter types.
Declaration
public T? CreateInstanceByType<T>(params Type?[] parameterTypes) where T : class
Parameters
| Type |
Name |
Description |
| Type[] |
parameterTypes |
|
Returns
Type Parameters
CreateInstance<T>(InstanceCreationFlags, params object?[])
Creates an instance of T using the supplied per-call construction flags.
Declaration
public T? CreateInstance<T>(InstanceCreationFlags flags, params object?[] args) where T : class
Parameters
Returns
Type Parameters
CreateInstance<T>(params object?[])
Creates an instance of T using the current component-construction defaults.
Declaration
public T? CreateInstance<T>(params object?[] args) where T : class
Parameters
| Type |
Name |
Description |
| object[] |
args |
|
Returns
Type Parameters
GetArgData<T>()
Builds constructor argument data for T using the mocker's current optional-parameter policy.
Declaration
public object?[] GetArgData<T>() where T : class
Returns
Type Parameters
GetArgData<T>(InstanceCreationFlags)
Builds constructor argument data for T using the supplied creation flags.
Declaration
public object?[] GetArgData<T>(InstanceCreationFlags flags) where T : class
Parameters
Returns
Type Parameters
GetArgData<T>(OptionalParameterResolutionMode)
Builds constructor argument data for T using the supplied optional-parameter policy.
Declaration
public object?[] GetArgData<T>(OptionalParameterResolutionMode optionalParameterResolution) where T : class
Parameters
Returns
Type Parameters
GetFileSystem()
Returns the shared mock file system.
Declaration
public IFileSystem GetFileSystem()
Returns
| Type |
Description |
| IFileSystem |
|
GetFileSystem(Action<MockFileSystem>?)
Returns the shared mock file system after optionally applying additional configuration.
Declaration
public IFileSystem GetFileSystem(Action<MockFileSystem>? configure = null)
Parameters
| Type |
Name |
Description |
| Action<MockFileSystem> |
configure |
|
Returns
| Type |
Description |
| IFileSystem |
|
GetKeyedObject(Type, object, Action<object?>?)
Resolves a keyed object for the specified service type.
Declaration
public object? GetKeyedObject(Type type, object serviceKey, Action<object?>? initAction = null)
Parameters
Returns
GetKeyedObject<T>(object)
Resolves a keyed object using the supplied service key.
Declaration
public T? GetKeyedObject<T>(object serviceKey) where T : class
Parameters
| Type |
Name |
Description |
| object |
serviceKey |
|
Returns
Type Parameters
GetKeyedObject<T>(object, Action<T?>)
Resolves a keyed object and invokes an initialization callback with the typed result.
Declaration
public T? GetKeyedObject<T>(object serviceKey, Action<T?> init) where T : class
Parameters
Returns
Type Parameters
GetList<T>(int, Func<int, T>)
Creates a list by invoking the supplied indexed factory a fixed number of times.
Declaration
public static List<T> GetList<T>(int count, Func<int, T> factory)
Parameters
| Type |
Name |
Description |
| int |
count |
|
| Func<int, T> |
factory |
|
Returns
Type Parameters
GetList<T>(int, Func<int, T>, Action<int, T>)
Creates a list by invoking the supplied indexed factory and initializer a fixed number of times.
Declaration
public static List<T> GetList<T>(int count, Func<int, T> factory, Action<int, T> init)
Parameters
Returns
Type Parameters
GetList<T>(int, Func<T>)
Creates a list by invoking the supplied factory a fixed number of times.
Declaration
public static List<T> GetList<T>(int count, Func<T> factory)
Parameters
| Type |
Name |
Description |
| int |
count |
|
| Func<T> |
factory |
|
Returns
Type Parameters
GetMethodArgData(MethodBase?)
Builds invocation arguments for a method using the mocker's current optional-parameter policy.
Declaration
public object?[] GetMethodArgData(MethodBase? method)
Parameters
Returns
GetMethodArgData(MethodBase?, InvocationOptions?)
Builds invocation arguments for a method using the supplied invocation options.
Declaration
public object?[] GetMethodArgData(MethodBase? method, InvocationOptions? options)
Parameters
Returns
GetMethodDefaultData(MethodBase?)
Builds invocation arguments that contain only default values for the supplied method.
Declaration
public object?[] GetMethodDefaultData(MethodBase? method)
Parameters
Returns
GetMockModel<T>()
Gets the tracked mock model for the supplied type parameter.
Declaration
public MockModel<T> GetMockModel<T>() where T : class
Returns
Type Parameters
GetNativeMock(Type)
Gets the provider-native mock object for the supplied runtime type.
Declaration
public object GetNativeMock(Type type)
Parameters
| Type |
Name |
Description |
| Type |
type |
|
Returns
GetNativeMock<T>(params object?[])
Gets the provider-native mock object for the supplied type parameter.
Declaration
public object GetNativeMock<T>(params object?[] args) where T : class
Parameters
| Type |
Name |
Description |
| object[] |
args |
|
Returns
Type Parameters
GetObject(ParameterInfo)
Resolves a value for the supplied parameter using the mocker's constructor and object-resolution rules.
Declaration
public object? GetObject(ParameterInfo info)
Parameters
| Type |
Name |
Description |
| ParameterInfo |
info |
The parameter to resolve.
|
Returns
| Type |
Description |
| object |
The resolved value, or the parameter type default when resolution fails.
|
GetObject(Type, Action<object?>?)
Resolves an object using custom registrations, known types, tracked mocks, and default fallbacks.
Declaration
public object? GetObject(Type type, Action<object?>? initAction = null)
Parameters
| Type |
Name |
Description |
| Type |
type |
The requested service or concrete type.
|
| Action<object> |
initAction |
Optional callback invoked with the resolved value before it is returned.
|
Returns
| Type |
Description |
| object |
The resolved object instance, or the type default when no value can be created.
|
GetObject<T>()
Resolves an object using FastMoq's runtime resolution pipeline.
Declaration
public T? GetObject<T>() where T : class
Returns
Type Parameters
Examples
Resolve a dependency after configuring a concrete registration through the provider-first pipeline.
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory(@"c:\exports");
var mocker = new Mocker()
.AddType<IFileSystem>(fileSystem);
var resolvedFileSystem = mocker.GetRequiredObject<IFileSystem>();
resolvedFileSystem.Directory.Exists(@"c:\exports").Should().BeTrue();
GetObject<T>(Action<T?>)
Resolves an object and invokes an initialization callback with the typed result.
Declaration
public T? GetObject<T>(Action<T?> init) where T : class
Parameters
| Type |
Name |
Description |
| Action<T> |
init |
|
Returns
Type Parameters
GetObject<T>(object?[])
Creates an instance of T using the supplied constructor arguments.
Declaration
public T? GetObject<T>(object?[] args) where T : class
Parameters
| Type |
Name |
Description |
| object[] |
args |
|
Returns
Type Parameters
GetOrCreateMock(Type, MockRequestOptions?)
Gets an existing tracked provider-backed mock or creates and tracks one when it does not yet exist.
Declaration
public IFastMock GetOrCreateMock(Type type, MockRequestOptions? options = null)
Parameters
Returns
GetOrCreateMock<T>(MockRequestOptions?)
Gets an existing tracked provider-backed mock or creates and tracks one when it does not yet exist.
Declaration
public IFastMock<T> GetOrCreateMock<T>(MockRequestOptions? options = null) where T : class
Parameters
Returns
Type Parameters
Examples
Use GetOrCreateMock<T>(MockRequestOptions?) when the test needs the tracked mock handle itself, not just automatic constructor resolution.
GetOrCreateMock uses the active FastMoq provider. It does not require the Moq provider to be selected unless the test later calls Moq-specific extensions such as AsMoq(), Setup(...), or Protected().
var mocker = new Mocker();
var gateway = mocker.GetOrCreateMock<IOrderGateway>();
var submitter = new OrderSubmitter(gateway.Instance);
submitter.Submit(42);
mocker.Verify<IOrderGateway>(x => x.Publish(42), TimesSpec.Once);
mocker.VerifyNoOtherCalls<IOrderGateway>();
Provider-neutral usage works the same way under the reflection provider because the tracked handle is still an IFastMock<T>.
using var providerScope = MockingProviderRegistry.Push("reflection");
var mocker = new Mocker();
var dependency = mocker.GetOrCreateMock<IOrderGateway>();
var submitter = new OrderSubmitter(dependency.Instance);
submitter.Submit(42);
mocker.Verify<IOrderGateway>(x => x.Publish(42), TimesSpec.Once);
Typical reasons to call it explicitly are: passing Instance into custom component construction, reusing the same tracked mock across calls, resetting it, or using keyed MockRequestOptions. If the test needs Moq-specific setup or verification APIs, select the Moq provider for that test assembly before calling those extensions.
GetRequiredObject<T>()
Resolves a required object and throws when no instance can be produced.
Declaration
public T GetRequiredObject<T>() where T : class
Returns
Type Parameters
GetStringContent(HttpContent?)
Reads the string content from an HttpContent instance, returning an empty string when the content is null.
Declaration
public Task<string> GetStringContent(HttpContent? content)
Parameters
Returns
HasParameterlessConstructor(Type, bool)
Determines whether the supplied type exposes a parameterless constructor.
Declaration
public bool HasParameterlessConstructor(Type type, bool nonPublic = false)
Parameters
| Type |
Name |
Description |
| Type |
type |
|
| bool |
nonPublic |
|
Returns
InvokeMethod(InvocationOptions?, object?, string, bool, params object?[])
Invokes a method on the supplied instance using the supplied invocation options.
Declaration
public object? InvokeMethod(InvocationOptions? options, object? instance, string methodName, bool nonPublic = false, params object?[] args)
Parameters
Returns
InvokeMethod(object?, string, bool, params object?[])
Invokes a method on the supplied instance using the mocker's current invocation defaults.
Declaration
public object? InvokeMethod(object? instance, string methodName, bool nonPublic = false, params object?[] args)
Parameters
Returns
InvokeMethod<T>(InvocationOptions?, object?, string, bool, params object?[])
Invokes a method declared on T using the supplied invocation options.
Declaration
public object? InvokeMethod<T>(InvocationOptions? options, object? instance, string methodName, bool nonPublic = false, params object?[] args)
Parameters
Returns
Type Parameters
InvokeMethod<T>(InvocationOptions?, string, bool, params object?[])
Invokes a method declared on T without an explicit instance parameter using the supplied invocation options.
Declaration
public object? InvokeMethod<T>(InvocationOptions? options, string methodName, bool nonPublic = false, params object?[] args)
Parameters
Returns
Type Parameters
InvokeMethod<T>(object?, string, bool, params object?[])
Invokes a method declared on T using the mocker's current invocation defaults.
Declaration
public object? InvokeMethod<T>(object? instance, string methodName, bool nonPublic = false, params object?[] args)
Parameters
Returns
Type Parameters
InvokeMethod<T>(string, bool, params object?[])
Invokes a method declared on T without an explicit instance parameter.
Declaration
public object? InvokeMethod<T>(string methodName, bool nonPublic = false, params object?[] args)
Parameters
Returns
Type Parameters
Scenario<T>(T?)
Creates a new fluent scenario builder for the specified component type using provider-first creation.
Declaration
public ScenarioBuilder<T> Scenario<T>(T? instance = null) where T : class
Parameters
| Type |
Name |
Description |
| T |
instance |
|
Returns
Type Parameters
UseLenientPreset()
Applies the predefined lenient behavior preset.
This is broader than disabling FailOnUnconfigured alone.
Declaration
public void UseLenientPreset()
UseStrictPreset()
Applies the predefined strict behavior preset.
This is broader than FastMoq.Mocker.Strict, which is retained for backward compatibility.
Declaration
public void UseStrictPreset()
VerifyNoOtherCalls<T>()
Ensures no other calls were made for a given mock (provider-first only).
Declaration
public void VerifyNoOtherCalls<T>() where T : class
Type Parameters
Verify<T>(Expression<Action<T>>, TimesSpec?)
Provider-first verification helper (provider agnostic).
Declaration
public void Verify<T>(Expression<Action<T>> expression, TimesSpec? times = null) where T : class
Parameters
Type Parameters
Extension Methods