MockExtensions.SetupWithAny<T> method (1 of 2)

April 20, 2021 · View on GitHub

Specifies a setup on the mocked type for a call to a void method. All parameters are filled with IsAny according to the parameter's type.

public static ISetup<T> SetupWithAny<T>(this Mock<T> mock, string methodName)
    where T : class
parameterdescription
TType of the mock
mockThe mock
methodNameThe name of the expected method invocation.

Exceptions

exceptioncondition
ArgumentNullExceptionWhen mock or methodName is null.
MissingMethodExceptionThrown when no method with methodName is found.
AmbiguousMatchExceptionThrown when more that one method matches the passed method name.

Remarks

This may only be used on methods that are not overloaded.

See Also


MockExtensions.SetupWithAny<T,TResult> method (2 of 2)

Specifies a setup on the mocked type for a call to a non-void (value-returning) method. All parameters are filled with IsAny according to the parameter's type.

public static ISetup<T, TResult> SetupWithAny<T, TResult>(this Mock<T> mock, string methodName)
    where T : class
parameterdescription
TType of the mock
TResultThe return type of the method
mockThe mock
methodNameThe name of the expected method invocation.

Exceptions

exceptioncondition
ArgumentNullExceptionWhen mock or methodName is null.
MissingMethodExceptionThrown when no method with methodName is found.
AmbiguousMatchExceptionThrown when more that one method matches the passed method name.

Remarks

This may only be used on methods that are not overloaded.

See Also