Moq Namespace

Moq
Moq Namespace
Send Feedback
Root namespace of Moq (pronounced "Mock-you" or just "Mock"), the only mocking library for .NET and Silverlight developed from scratch to take full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features (i.e. lambda expressions) that make it the most productive, simple and refactoring-friendly mocking library available.

See the online quickstarts for more examples than those available in this code documentation.

The Mock<T> class is the core of the library, so it's a good place to start.

You can also read blog entries from around the world about Moq.

Classes

 | Class | Description
Public class | It | Allows the specification of a matching condition for an argument in a method invocation, rather than a specific argument value. "It" refers to the argument being matched.
Public class | Mock | Base class for mocks and static helper class with methods that apply to mocked objects, such as Get<(Of <<'(T>)>>)(T) to retrieve a Mock<(Of <(<'T>)>)> from an object instance.
Public class | Mock<(Of <(<'T>)>)> | Provides a mock implementation of T.
Public class | MockException | Exception thrown by mocks when setups are not matched, the mock is not properly setup, etc.
Public class | MockExtensions | Provides additional methods on mocks.
Public class | MockFactory | Obsolete. Utility factory class to use to construct multiple mocks when consistent verification is desired for all of them.
Public class | MockRepository | Utility repository class to use to construct multiple mocks when consistent verification is desired for all of them.
Public class | Mocks | Allows querying the universe of mocks for those that behave according to the LINQ query specification.
Public class | MockSequence | Helper class to setup a full trace between many mocks
Public class | MockSequenceHelper | define nice api
Public class | SequenceExtensions | Helper for sequencing return values in the same method.

Structures

 | Structure | Description
Public structure | Times | Defines the number of invocations allowed by a mocked method.

Enumerations

 | Enumeration | Description
Public enumeration | DefaultValue | Determines the way default values are generated calculated for loose mocks.
Public enumeration | MockBehavior | Options to customize the behavior of the mock.
Public enumeration | Range | Kind of range to use in a filter specified through IsInRange<(Of <<'(TValue>)>>)(TValue, TValue, Range).

Send comments on this topic to moqdisc@googlegroups.com


DefaultValue Enumeration

DefaultValue Enumeration
See Also Send Feedback
Determines the way default values are generated calculated for loose mocks.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public enum DefaultValue

Members

Member name | Description
Empty |
Mock |

See Also

Moq Namespace


It Class

It Class
Members See Also Send Feedback
Allows the specification of a matching condition for an argument in a method invocation, rather than a specific argument value. "It" refers to the argument being matched.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class It

Remarks

This class allows the setup to match a method invocation with an arbitrary value, with a value in a specified range, or even one that matches a given predicate.

Inheritance Hierarchy

System..::..Object
Moq..::..It

See Also

It Members
Moq Namespace


It Members

[image]

Moq
It Members
It Class Methods See Also Send Feedback

The It type exposes the following members.

Methods

Name | Description
Is<(Of <<'(TValue>)>>) |
IsAny<(Of <<'(TValue>)>>) | Matches any value of the given TValue type.
IsInRange<(Of <<'(TValue>)>>) | Matches any value that is in the range specified.
IsRegex(String) | Matches a string argument if it matches the given regular expression pattern.
IsRegex(String, RegexOptions) | Matches a string argument if it matches the given regular expression pattern.

See Also

It Class
Moq Namespace


It Methods

[image]

Moq
It Methods
It Class See Also Send Feedback

The It type exposes the following members.

Methods

Name | Description
Is<(Of <<'(TValue>)>>) |
IsAny<(Of <<'(TValue>)>>) | Matches any value of the given TValue type.
IsInRange<(Of <<'(TValue>)>>) | Matches any value that is in the range specified.
IsRegex(String) | Matches a string argument if it matches the given regular expression pattern.
IsRegex(String, RegexOptions) | Matches a string argument if it matches the given regular expression pattern.

See Also

It Class
Moq Namespace


Is(TValue) Method

It..::..Is<(Of <(<'TValue>)>)> Method
It Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.It.Is``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static TValue Is<TValue>(
    Expression<Func> match
)

Parameters

match
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TValue

See Also

It Class
Moq Namespace


IsAny(TValue) Method

It..::..IsAny<(Of <(<'TValue>)>)> Method
It Class Example See Also Send Feedback
Matches any value of the given TValue type.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static TValue IsAny<TValue>()

Type Parameters

TValue
Type of the value.

Remarks

Typically used when the actual argument value for a method call is not relevant.

Examples

CopyC#
// Throws an exception for a call to Remove with any string value.
mock.Setup(x => x.Remove(It.IsAny<string>())).Throws(new InvalidOperationException());

See Also

It Class
Moq Namespace


IsInRange(TValue) Method

It..::..IsInRange<(Of <(<'TValue>)>)> Method
It Class Example See Also Send Feedback
Matches any value that is in the range specified.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static TValue IsInRange<TValue>(
    TValue from,
    TValue to,
    Range rangeKind
)
where TValue : IComparable

Parameters

from
Type: TValue
The lower bound of the range.
to
Type: TValue
The upper bound of the range.
rangeKind
Type: Moq..::..Range
The kind of range. See Range.

Type Parameters

TValue
Type of the argument to check.

Examples

The following example shows how to expect a method call with an integer argument within the 0..100 range.
CopyC#
mock.Setup(x => x.HasInventory(
It.IsAny<string>(),
It.IsInRange(0, 100, Range.Inclusive)))
.Returns(false);

See Also

It Class
Moq Namespace


IsRegex Method

[image]

Moq
It..::..IsRegex Method
It Class See Also Send Feedback

Overload List

Name | Description
IsRegex(String) | Matches a string argument if it matches the given regular expression pattern.
IsRegex(String, RegexOptions) | Matches a string argument if it matches the given regular expression pattern.

See Also

It Class
It Members
Moq Namespace


IsRegex Method (String)

It..::..IsRegex Method (String)
It Class Example See Also Send Feedback
Matches a string argument if it matches the given regular expression pattern.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static string IsRegex(
    string regex
)

Parameters

regex
Type: System..::..String
The pattern to use to match the string argument value.

Examples

The following example shows how to expect a call to a method where the string argument matches the given regular expression:
CopyC#
mock.Setup(x => x.Check(It.IsRegex("[a-z]+"))).Returns(1);

See Also

It Class
IsRegex Overload
Moq Namespace


IsRegex Method (String, RegexOptions)

It..::..IsRegex Method (String, RegexOptions)
It Class Example See Also Send Feedback
Matches a string argument if it matches the given regular expression pattern.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static string IsRegex(
    string regex,
    RegexOptions options
)

Parameters

regex
Type: System..::..String
The pattern to use to match the string argument value.
options
Type: System.Text.RegularExpressions..::..RegexOptions
The options used to interpret the pattern.

Examples

The following example shows how to expect a call to a method where the string argument matches the given regular expression, in a case insensitive way:
CopyC#
mock.Setup(x => x.Check(It.IsRegex("[a-z]+", RegexOptions.IgnoreCase))).Returns(1);

See Also

It Class
IsRegex Overload
Moq Namespace


Mock Class

Mock Class
Members See Also Send Feedback
Base class for mocks and static helper class with methods that apply to mocked objects, such as Get<(Of <<'(T>)>>)(T) to retrieve a Mock<(Of <(<'T>)>)> from an object instance.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public abstract class Mock : IHideObjectMembers

Inheritance Hierarchy

System..::..Object
Moq..::..Mock
Moq..::..Mock<(Of <(<'T>)>)>

See Also

Mock Members
Moq Namespace


Mock Members

[image]

Moq
Mock Members
Mock Class Constructors Methods Properties See Also Send Feedback

The Mock type exposes the following members.

Constructors

 | Name | Description
Protected method | Mock | Initializes a new instance of the Mock class.

Methods

 | Name | Description
Public method | As<(Of <<'(TInterface>)>>) | Adds an interface implementation to the mock, allowing setups to be specified for it.
 | Get<(Of <<'(T>)>>) | Retrieves the mock object for the given object instance.
 | Of<(Of <<'(T>)>>)()()()() | Creates an mock object of the indicated type.
 | Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Protected method | OnGetObject | Returns the mocked object value.
Public method | SetReturnsDefault<(Of <<'(TReturn>)>>) |
Public method | Verify | Verifies that all verifiable expectations have been met.
Public method | VerifyAll | Verifies all expectations regardless of whether they have been flagged as verifiable.

Properties

 | Name | Description
Public property | Behavior | Behavior of the mock, according to the value set in the constructor.
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic).
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks.
Public property | Object | Gets the mocked object instance.

See Also

Mock Class
Moq Namespace


Mock Constructor

Mock Constructor
Mock Class See Also Send Feedback
Initializes a new instance of the Mock class.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected Mock()

See Also

Mock Class
Moq Namespace


Mock Methods

[image]

Moq
Mock Methods
Mock Class See Also Send Feedback

The Mock type exposes the following members.

Methods

 | Name | Description
Public method | As<(Of <<'(TInterface>)>>) | Adds an interface implementation to the mock, allowing setups to be specified for it.
 | Get<(Of <<'(T>)>>) | Retrieves the mock object for the given object instance.
 | Of<(Of <<'(T>)>>)()()()() | Creates an mock object of the indicated type.
 | Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Protected method | OnGetObject | Returns the mocked object value.
Public method | SetReturnsDefault<(Of <<'(TReturn>)>>) |
Public method | Verify | Verifies that all verifiable expectations have been met.
Public method | VerifyAll | Verifies all expectations regardless of whether they have been flagged as verifiable.

See Also

Mock Class
Moq Namespace


As(TInterface) Method

Mock..::..As<(Of <(<'TInterface>)>)> Method
Mock Class Example See Also Send Feedback
Adds an interface implementation to the mock, allowing setups to be specified for it.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual Mock<TInterface> As<TInterface>()
where TInterface : class

Type Parameters

TInterface
Type of interface to cast the mock to.

Remarks

This method can only be called before the first use of the mock Object property, at which point the runtime type has already been generated and no more interfaces can be added to it.

Also, TInterface must be an interface and not a class, which must be specified when creating the mock instead.

Examples

The following example creates a mock for the main interface and later adds IDisposable to it to verify it's called by the consumer code:
CopyC#
var mock = new Mock<IProcessor>();
mock.Setup(x => x.Execute("ping"));

// add IDisposable interface
var disposable = mock.As<IDisposable>();
disposable.Setup(d => d.Dispose()).Verifiable();

Exceptions

Exception | Condition
System..::..InvalidOperationException | The mock type has already been generated by accessing the Object property.
System..::..ArgumentException | The TInterface specified is not an interface.

See Also

Mock Class
Moq Namespace


Get(T) Method

Mock..::..Get<(Of <(<'T>)>)> Method
Mock Class Example See Also Send Feedback
Retrieves the mock object for the given object instance.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Mock<T> Get<T>(
    T mocked
)
where T : class

Parameters

mocked
Type: T
The instance of the mocked object.

Type Parameters

T
Type of the mock to retrieve. Can be omitted as it's inferred from the object instance passed in as the mocked instance.

Return Value

The mock associated with the mocked object.

Examples

The following example shows how to add a new setup to an object instance which is not the original Mock<(Of <(<'T>)>)> but rather the object associated with it:
CopyC#
// Typed instance, not the mock, is retrieved from some test API.
HttpContextBase context = GetMockContext();

// context.Request is the typed object from the "real" API
// so in order to add a setup to it, we need to get
// the mock that "owns" it
Mock<HttpRequestBase> request = Mock.Get(context.Request);
mock.Setup(req => req.AppRelativeCurrentExecutionFilePath)
     .Returns(tempUrl);

Exceptions

Exception | Condition
System..::..ArgumentException | The received mocked instance was not created by Moq.

See Also

Mock Class
Moq Namespace


Of Method

[image]

Moq
Mock..::..Of Method
Mock Class See Also Send Feedback

Overload List

Name | Description
Of<(Of <<'(T>)>>)()()()() | Creates an mock object of the indicated type.
Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |

See Also

Mock Class
Mock Members
Moq Namespace


Of(T) Method

Mock..::..Of<(Of <(<'T>)>)> Method
Mock Class See Also Send Feedback
Creates an mock object of the indicated type.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static T Of<T>()
where T : class

Type Parameters

T
The type of the mocked object.

Return Value

The mocked object created.

See Also

Mock Class
Of Overload
Moq Namespace


Of(T) Method (Expression(Func))

Mock..::..Of<(Of <(<'T>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mock Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock.Of``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static T Of<T>(
    Expression<Func> predicate
)
where T : class

Parameters

predicate
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T

See Also

Mock Class
Of Overload
Moq Namespace


OnGetObject Method

Mock..::..OnGetObject Method
Mock Class See Also Send Feedback
Returns the mocked object value.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected abstract Object OnGetObject()

See Also

Mock Class
Moq Namespace


SetReturnsDefault(TReturn) Method

Mock..::..SetReturnsDefault<(Of <(<'TReturn>)>)> Method
Mock Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock.SetReturnsDefault``1(``0)"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void SetReturnsDefault<TReturn>(
    TReturn value
)

Parameters

value
Type: TReturn

Type Parameters

TReturn

See Also

Mock Class
Moq Namespace


Verify Method

Mock..::..Verify Method
Mock Class Example See Also Send Feedback
Verifies that all verifiable expectations have been met.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify()

Examples

This example sets up an expectation and marks it as verifiable. After the mock is used, a Verify() call is issued on the mock to ensure the method in the setup was invoked:
CopyC#
var mock = new Mock<IWarehouse>();
this.Setup(x => x.HasInventory(TALISKER, 50)).Verifiable().Returns(true);
...
// other test code
...
// Will throw if the test code has didn't call HasInventory.
this.Verify();

Exceptions

Exception | Condition
Moq..::..MockException | Not all verifiable expectations were met.

See Also

Mock Class
Moq Namespace


VerifyAll Method

Mock..::..VerifyAll Method
Mock Class Example See Also Send Feedback
Verifies all expectations regardless of whether they have been flagged as verifiable.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifyAll()

Examples

This example sets up an expectation without marking it as verifiable. After the mock is used, a VerifyAll()()()() call is issued on the mock to ensure that all expectations are met:
CopyC#
var mock = new Mock<IWarehouse>();
this.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true);
...
// other test code
...
// Will throw if the test code has didn't call HasInventory, even
// that expectation was not marked as verifiable.
this.VerifyAll();

Exceptions

Exception | Condition
Moq..::..MockException | At least one expectation was not met.

See Also

Mock Class
Moq Namespace


Mock Properties

[image]

Moq
Mock Properties
Mock Class See Also Send Feedback

The Mock type exposes the following members.

Properties

 | Name | Description
Public property | Behavior | Behavior of the mock, according to the value set in the constructor.
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic).
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks.
Public property | Object | Gets the mocked object instance.

See Also

Mock Class
Moq Namespace


Behavior Property

Mock..::..Behavior Property
Mock Class See Also Send Feedback
Behavior of the mock, according to the value set in the constructor.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual MockBehavior Behavior { get; internal set; }

See Also

Mock Class
Moq Namespace


CallBase Property

Mock..::..CallBase Property
Mock Class See Also Send Feedback
Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic).

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual bool CallBase { get; set; }

See Also

Mock Class
Moq Namespace


DefaultValue Property

Mock..::..DefaultValue Property
Mock Class See Also Send Feedback
Specifies the behavior to use when returning default values for unexpected invocations on loose mocks.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual DefaultValue DefaultValue { get; set; }

See Also

Mock Class
Moq Namespace


Object Property

Mock..::..Object Property
Mock Class See Also Send Feedback
Gets the mocked object instance.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Object Object { get; }

See Also

Mock Class
Moq Namespace


Mock(T) Class

Mock<(Of <(<'T>)>)> Class
Members Example See Also Send Feedback
Provides a mock implementation of T.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public class Mock<T> : Mock
where T : class

Type Parameters

T
Type to mock, which can be an interface or a class.

Remarks

Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked.

The behavior of the mock with regards to the setups and the actual calls is determined by the optional MockBehavior that can be passed to the Mock<(Of <(<'T>)>)>(MockBehavior) constructor.

Examples

The following example shows establishing setups with specific values for method invocations:
CopyC#
// Arrange
var order = new Order(TALISKER, 50);
var mock = new Mock<IWarehouse>();

mock.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true);

// Act
order.Fill(mock.Object);

// Assert
Assert.True(order.IsFilled);
 The following example shows how to use the It class to specify conditions for arguments instead of specific values:
CopyC#
// Arrange
var order = new Order(TALISKER, 50);
var mock = new Mock<IWarehouse>();

// shows how to expect a value within a range
mock.Setup(x => x.HasInventory(
            It.IsAny<string>(),
            It.IsInRange(0, 100, Range.Inclusive)))
     .Returns(false);

// shows how to throw for unexpected calls.
mock.Setup(x => x.Remove(
            It.IsAny<string>(),
            It.IsAny<int>()))
     .Throws(new InvalidOperationException());

// Act
order.Fill(mock.Object);

// Assert
Assert.False(order.IsFilled);

Inheritance Hierarchy

System..::..Object
Moq..::..Mock
Moq..::..Mock<(Of <(<'T>)>)>

See Also

Mock<(Of <(<'T>)>)> Members
Moq Namespace


Mock(T) Members

[image]

Moq
Mock<(Of <(<'T>)>)> Members
Mock<(Of <(<'T>)>)> Class Constructors Methods Properties See Also Send Feedback

The Mock<(Of <(<'T>)>)> type exposes the following members.

Constructors

 | Name | Description
Public method | Mock<(Of <(<'T>)>)>()()()() | Initializes an instance of the mock with default behavior.
Public method | Mock<(Of <(<'T>)>)>(array<Object>[]()[][]) | Initializes an instance of the mock with default behavior and with the given constructor arguments for the class. (Only valid when T is a class)
Public method | Mock<(Of <(<'T>)>)>(MockBehavior) | Initializes an instance of the mock with the specified behavior.
Public method | Mock<(Of <(<'T>)>)>(MockBehavior, array<Object>[]()[][]) | Initializes an instance of the mock with a specific behavior with the given constructor arguments for the class.

Methods

 | Name | Description
Public method | As<(Of <<'(TInterface>)>>) | Adds an interface implementation to the mock, allowing setups to be specified for it. (Inherited from Mock.)
Protected method | OnGetObject | Returns the mocked object value. (Overrides Mock..::..OnGetObject()()()().)
Public method | Raise(Action<(Of <<'(T>)>>), EventArgs) | Raises the event referenced in eventExpression using the given args argument.
Public method | Raise(Action<(Of <<'(T>)>>), array<Object>[]()[][]) | Raises the event referenced in eventExpression using the given args argument for a non-EventHandler typed event.
Public method | SetReturnsDefault<(Of <<'(TReturn>)>>) | (Inherited from Mock.)
Public method | Setup(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | Specifies a setup on the mocked type for a call to to a void method.
Public method | Setup<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupAllProperties | Specifies that the all properties on the mock should have "property behavior", meaning that setting its value will cause it to be saved and later returned when the property is requested. (this is also known as "stubbing"). The default value for each property will be the one generated as specified by the DefaultValue property for the mock.
Public method | SetupGet<(Of <<'(TProperty>)>>) |
Public method | SetupProperty<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupProperty<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | SetupSet(Action<(Of <<'(T>)>>)) | Specifies a setup on the mocked type for a call to to a property setter.
Public method | SetupSet<(Of <<'(TProperty>)>>)(Action<(Of <<'(T>)>>)) | Specifies a setup on the mocked type for a call to to a property setter.
Public method | Verify()()()() | Verifies that all verifiable expectations have been met. (Inherited from Mock.)
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), Times) | Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), String) | Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), Times, String) | Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) |
Public method | VerifyAll | Verifies all expectations regardless of whether they have been flagged as verifiable. (Inherited from Mock.)
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) |
Public method | VerifySet(Action<(Of <<'(T>)>>)) | Verifies that a property was set on the mock.
Public method | VerifySet(Action<(Of <<'(T>)>>), Times) | Verifies that a property was set on the mock.
Public method | VerifySet(Action<(Of <<'(T>)>>), String) | Verifies that a property was set on the mock, specifying a failure message.
Public method | VerifySet(Action<(Of <<'(T>)>>), Times, String) | Verifies that a property was set on the mock, specifying a failure message.
Public method | When |

Extension Methods

 | Name | Description
Public Extension Method | InSequence<(Of <<'(TMock>)>>) | Perform an expectation in the trace. (Defined by MockSequenceHelper.)
Public Extension Method | Protected<(Of <<'(T>)>>) | Enable protected setups for the mock. (Defined by ProtectedExtension.)
Public Extension Method | SetupSequence<(Of <<'(TMock, TResult>)>>) | (Defined by SequenceExtensions.)
Public Extension Method | SetupSet<(Of <<'(T, TProperty>)>>) | (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Overloaded. (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Overloaded. (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Overloaded. (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) | Overloaded. (Defined by MockExtensions.)

Properties

 | Name | Description
Public property | Behavior | Behavior of the mock, according to the value set in the constructor. (Inherited from Mock.)
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic). (Inherited from Mock.)
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks. (Inherited from Mock.)
Public property | Object | Exposes the mocked object instance.

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


Mock(T) Constructor

[image]

Moq
Mock<(Of <(<'T>)>)> Constructor
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Mock<(Of <(<'T>)>)>()()()() | Initializes an instance of the mock with default behavior.
Public method | Mock<(Of <(<'T>)>)>(array<Object>[]()[][]) | Initializes an instance of the mock with default behavior and with the given constructor arguments for the class. (Only valid when T is a class)
Public method | Mock<(Of <(<'T>)>)>(MockBehavior) | Initializes an instance of the mock with the specified behavior.
Public method | Mock<(Of <(<'T>)>)>(MockBehavior, array<Object>[]()[][]) | Initializes an instance of the mock with a specific behavior with the given constructor arguments for the class.

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


Mock(T) Constructor

Mock<(Of <(<'T>)>)> Constructor
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Initializes an instance of the mock with default behavior.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock()

Examples

CopyC#
var mock = new Mock<IFormatProvider>();

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Overload
Moq Namespace


Mock(T) Constructor (Object[])

Mock<(Of <(<'T>)>)> Constructor (array<Object>[]()[][])
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Initializes an instance of the mock with default behavior and with the given constructor arguments for the class. (Only valid when T is a class)

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock(
    params Object[] args
)

Parameters

args
Type: array< System..::..Object >[]()[][]
Optional constructor arguments if the mocked type is a class.

Remarks

The mock will try to find the best match constructor given the constructor arguments, and invoke that to initialize the instance. This applies only for classes, not interfaces.

Examples

CopyC#
var mock = new Mock<MyProvider>(someArgument, 25);

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Overload
Moq Namespace


Mock(T) Constructor (MockBehavior)

Mock<(Of <(<'T>)>)> Constructor (MockBehavior)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Initializes an instance of the mock with the specified behavior.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock(
    MockBehavior behavior
)

Parameters

behavior
Type: Moq..::..MockBehavior
Behavior of the mock.

Examples

CopyC#
var mock = new Mock<IFormatProvider>(MockBehavior.Relaxed);

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Overload
Moq Namespace


Mock(T) Constructor (MockBehavior, Object[])

Mock<(Of <(<'T>)>)> Constructor (MockBehavior, array<Object>[]()[][])
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Initializes an instance of the mock with a specific behavior with the given constructor arguments for the class.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock(
    MockBehavior behavior,
    params Object[] args
)

Parameters

behavior
Type: Moq..::..MockBehavior
Behavior of the mock.
args
Type: array< System..::..Object >[]()[][]
Optional constructor arguments if the mocked type is a class.

Remarks

The mock will try to find the best match constructor given the constructor arguments, and invoke that to initialize the instance. This applies only to classes, not interfaces.

Examples

CopyC#
var mock = new Mock<MyProvider>(someArgument, 25);

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Overload
Moq Namespace


Mock(T) Methods

[image]

Moq
Mock<(Of <(<'T>)>)> Methods
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

The Mock<(Of <(<'T>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | As<(Of <<'(TInterface>)>>) | Adds an interface implementation to the mock, allowing setups to be specified for it. (Inherited from Mock.)
Protected method | OnGetObject | Returns the mocked object value. (Overrides Mock..::..OnGetObject()()()().)
Public method | Raise(Action<(Of <<'(T>)>>), EventArgs) | Raises the event referenced in eventExpression using the given args argument.
Public method | Raise(Action<(Of <<'(T>)>>), array<Object>[]()[][]) | Raises the event referenced in eventExpression using the given args argument for a non-EventHandler typed event.
Public method | SetReturnsDefault<(Of <<'(TReturn>)>>) | (Inherited from Mock.)
Public method | Setup(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | Specifies a setup on the mocked type for a call to to a void method.
Public method | Setup<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupAllProperties | Specifies that the all properties on the mock should have "property behavior", meaning that setting its value will cause it to be saved and later returned when the property is requested. (this is also known as "stubbing"). The default value for each property will be the one generated as specified by the DefaultValue property for the mock.
Public method | SetupGet<(Of <<'(TProperty>)>>) |
Public method | SetupProperty<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupProperty<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | SetupSet(Action<(Of <<'(T>)>>)) | Specifies a setup on the mocked type for a call to to a property setter.
Public method | SetupSet<(Of <<'(TProperty>)>>)(Action<(Of <<'(T>)>>)) | Specifies a setup on the mocked type for a call to to a property setter.
Public method | Verify()()()() | Verifies that all verifiable expectations have been met. (Inherited from Mock.)
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), Times) | Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), String) | Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), Times, String) | Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) |
Public method | VerifyAll | Verifies all expectations regardless of whether they have been flagged as verifiable. (Inherited from Mock.)
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) |
Public method | VerifySet(Action<(Of <<'(T>)>>)) | Verifies that a property was set on the mock.
Public method | VerifySet(Action<(Of <<'(T>)>>), Times) | Verifies that a property was set on the mock.
Public method | VerifySet(Action<(Of <<'(T>)>>), String) | Verifies that a property was set on the mock, specifying a failure message.
Public method | VerifySet(Action<(Of <<'(T>)>>), Times, String) | Verifies that a property was set on the mock, specifying a failure message.
Public method | When |

Extension Methods

 | Name | Description
Public Extension Method | InSequence<(Of <<'(TMock>)>>) | Perform an expectation in the trace. (Defined by MockSequenceHelper.)
Public Extension Method | Protected<(Of <<'(T>)>>) | Enable protected setups for the mock. (Defined by ProtectedExtension.)
Public Extension Method | SetupSequence<(Of <<'(TMock, TResult>)>>) | (Defined by SequenceExtensions.)
Public Extension Method | SetupSet<(Of <<'(T, TProperty>)>>) | (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Overloaded. (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Overloaded. (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Overloaded. (Defined by MockExtensions.)
Public Extension Method | VerifySet<(Of <<'(T, TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) | Overloaded. (Defined by MockExtensions.)

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


OnGetObject Method

Mock<(Of <(<'T>)>)>..::..OnGetObject Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Returns the mocked object value.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected override Object OnGetObject()

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


Raise Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..Raise Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Raise(Action<(Of <<'(T>)>>), EventArgs) | Raises the event referenced in eventExpression using the given args argument.
Public method | Raise(Action<(Of <<'(T>)>>), array<Object>[]()[][]) | Raises the event referenced in eventExpression using the given args argument for a non-EventHandler typed event.

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


Raise Method (Action(T), EventArgs)

Mock<(Of <(<'T>)>)>..::..Raise Method (Action<(Of <(<'T>)>)>, EventArgs)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Raises the event referenced in eventExpression using the given args argument.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Raise(
    Action<T> eventExpression,
    EventArgs args
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
args
Type: System..::..EventArgs

Examples

The following example shows how to raise a PropertyChanged event:
CopyC#
var mock = new Mock<IViewModel>();

mock.Raise(x => x.PropertyChanged -= null, new PropertyChangedEventArgs("Name"));

Examples

This example shows how to invoke an event with a custom event arguments class in a view that will cause its corresponding presenter to react by changing its state:
CopyC#
var mockView = new Mock<IOrdersView>();
var presenter = new OrdersPresenter(mockView.Object);

// Check that the presenter has no selection by default
Assert.Null(presenter.SelectedOrder);

// Raise the event with a specific arguments data
mockView.Raise(v => v.SelectionChanged += null, new OrderEventArgs { Order = new Order("moq", 500) });

// Now the presenter reacted to the event, and we have a selected order
Assert.NotNull(presenter.SelectedOrder);
Assert.Equal("moq", presenter.SelectedOrder.ProductName);

Exceptions

Exception | Condition
System..::..ArgumentException | The args argument is invalid for the target event invocation, or the eventExpression is not an event attach or detach expression.

See Also

Mock<(Of <(<'T>)>)> Class
Raise Overload
Moq Namespace


Raise Method (Action(T), Object[])

Mock<(Of <(<'T>)>)>..::..Raise Method (Action<(Of <(<'T>)>)>, array<Object>[]()[][])
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Raises the event referenced in eventExpression using the given args argument for a non-EventHandler typed event.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Raise(
    Action<T> eventExpression,
    params Object[] args
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
args
Type: array< System..::..Object >[]()[][]

Examples

The following example shows how to raise a custom event that does not adhere to the standard EventHandler:
CopyC#
var mock = new Mock<IViewModel>();

mock.Raise(x => x.MyEvent -= null, "Name", bool, 25);

Exceptions

Exception | Condition
System..::..ArgumentException | The args arguments are invalid for the target event invocation, or the eventExpression is not an event attach or detach expression.

See Also

Mock<(Of <(<'T>)>)> Class
Raise Overload
Moq Namespace


Setup Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..Setup Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Setup(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | Specifies a setup on the mocked type for a call to to a void method.
Public method | Setup<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


Setup Method (Expression(Action(T)))

Mock<(Of <(<'T>)>)>..::..Setup Method (Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Specifies a setup on the mocked type for a call to to a void method.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public ISetup<T> Setup(
    Expression<Action<T>> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Action <(Of <(<' T >)>)>>)>)>
Lambda expression that specifies the expected method invocation.

Remarks

If more than one setup is specified for the same method or property, the latest one wins and is the one that will be executed.

Examples

CopyC#
var mock = new Mock<IProcessor>();
mock.Setup(x => x.Execute("ping"));

See Also

Mock<(Of <(<'T>)>)> Class
Setup Overload
Moq Namespace


Setup(TResult) Method (Expression(Func))

Mock<(Of <(<'T>)>)>..::..Setup<(Of <(<'TResult>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.Setup``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public ISetup<T, TResult> Setup<TResult>(
    Expression<Func> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TResult

See Also

Mock<(Of <(<'T>)>)> Class
Setup Overload
Moq Namespace


SetupAllProperties Method

Mock<(Of <(<'T>)>)>..::..SetupAllProperties Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Specifies that the all properties on the mock should have "property behavior", meaning that setting its value will cause it to be saved and later returned when the property is requested. (this is also known as "stubbing"). The default value for each property will be the one generated as specified by the DefaultValue property for the mock.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> SetupAllProperties()

Remarks

If the mock DefaultValue is set to Mock, the mocked default values will also get all properties setup recursively.

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


SetupGet(TProperty) Method

Mock<(Of <(<'T>)>)>..::..SetupGet<(Of <(<'TProperty>)>)> Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.SetupGet``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public ISetupGetter<T, TProperty> SetupGet<TProperty>(
    Expression<Func> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TProperty

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


SetupProperty Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..SetupProperty Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | SetupProperty<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupProperty<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


SetupProperty(TProperty) Method (Expression(Func))

Mock<(Of <(<'T>)>)>..::..SetupProperty<(Of <(<'TProperty>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> SetupProperty<TProperty>(
    Expression<Func> property
)

Parameters

property
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TProperty

See Also

Mock<(Of <(<'T>)>)> Class
SetupProperty Overload
Moq Namespace


SetupProperty(TProperty) Method (Expression(Func), Boolean)

Mock<(Of <(<'T>)>)>..::..SetupProperty<(Of <(<'TProperty>)>)> Method (Expression<(Of <(<'Func>)>)>, Boolean)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> SetupProperty<TProperty>(
    Expression<Func> property,
    bool initialValue
)

Parameters

property
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
initialValue
Type: System..::..Boolean

Type Parameters

TProperty

See Also

Mock<(Of <(<'T>)>)> Class
SetupProperty Overload
Moq Namespace


SetupSet Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..SetupSet Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | SetupSet<(Of <<'(TProperty>)>>)(Action<(Of <<'(T>)>>)) | Specifies a setup on the mocked type for a call to to a property setter.
Public method | SetupSet(Action<(Of <<'(T>)>>)) | Specifies a setup on the mocked type for a call to to a property setter.

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


SetupSet(TProperty) Method (Action(T))

Mock<(Of <(<'T>)>)>..::..SetupSet<(Of <(<'TProperty>)>)> Method (Action<(Of <(<'T>)>)>)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Specifies a setup on the mocked type for a call to to a property setter.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public ISetupSetter<T, TProperty> SetupSet<TProperty>(
    Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
The Lambda expression that sets a property to a value.

Type Parameters

TProperty
Type of the property. Typically omitted as it can be inferred from the expression.

Remarks

If more than one setup is set for the same property setter, the latest one wins and is the one that will be executed.

This overloads allows the use of a callback already typed for the property type.

Examples

CopyC#
mock.SetupSet(x => x.Suspended = true);

See Also

Mock<(Of <(<'T>)>)> Class
SetupSet Overload
Moq Namespace


SetupSet Method (Action(T))

Mock<(Of <(<'T>)>)>..::..SetupSet Method (Action<(Of <(<'T>)>)>)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Specifies a setup on the mocked type for a call to to a property setter.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public ISetup<T> SetupSet(
    Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
Lambda expression that sets a property to a value.

Remarks

If more than one setup is set for the same property setter, the latest one wins and is the one that will be executed.

Examples

CopyC#
mock.SetupSet(x => x.Suspended = true);

See Also

Mock<(Of <(<'T>)>)> Class
SetupSet Overload
Moq Namespace


Verify Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..Verify Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Verify()()()() | Verifies that all verifiable expectations have been met. (Inherited from Mock.)
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), Times) | Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), String) | Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
 | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | Verify(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>), Times, String) | Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) |

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


Verify Method (Expression(Action(T)))

Mock<(Of <(<'T>)>)>..::..Verify Method (Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify(
    Expression<Action<T>> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Action <(Of <(<' T >)>)>>)>)>
Expression to verify.

Examples

This example assumes that the mock has been used, and later we want to verify that a given invocation with specific parameters was performed:
CopyC#
var mock = new Mock<IProcessor>();
// exercise mock
//...
// Will throw if the test code didn't call Execute with a "ping" string argument.
mock.Verify(proc => proc.Execute("ping"));

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not performed on the mock.

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


Verify(TResult) Method (Expression(Func))

Mock<(Of <(<'T>)>)>..::..Verify<(Of <(<'TResult>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify<TResult>(
    Expression<Func> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TResult

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


Verify Method (Expression(Action(T)), Times)

Mock<(Of <(<'T>)>)>..::..Verify Method (Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>, Times)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Verifies that a specific invocation matching the given expression was performed on the mock. Use in conjuntion with the default Loose.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify(
    Expression<Action<T>> expression,
    Times times
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Action <(Of <(<' T >)>)>>)>)>
Expression to verify.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


Verify Method (Expression(Action(T)), String)

Mock<(Of <(<'T>)>)>..::..Verify Method (Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>, String)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify(
    Expression<Action<T>> expression,
    string failMessage
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Action <(Of <(<' T >)>)>>)>)>
Expression to verify.
failMessage
Type: System..::..String
Message to show if verification fails.

Examples

This example assumes that the mock has been used, and later we want to verify that a given invocation with specific parameters was performed:
CopyC#
var mock = new Mock<IProcessor>();
// exercise mock
//...
// Will throw if the test code didn't call Execute with a "ping" string argument.
mock.Verify(proc => proc.Execute("ping"));

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not performed on the mock.

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


Verify(TResult) Method (Expression(Func), Boolean)

Mock<(Of <(<'T>)>)>..::..Verify<(Of <(<'TResult>)>)> Method (Expression<(Of <(<'Func>)>)>, Boolean)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]

Namespace: Moq
Assemblies: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)
Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify<TResult>(
    Expression<Func> expression,
    bool times
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
times
Type: System..::..Boolean

Type Parameters

TResult

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


Verify Method (Expression(Action(T)), Times, String)

Mock<(Of <(<'T>)>)>..::..Verify Method (Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>, Times, String)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Verifies that a specific invocation matching the given expression was performed on the mock, specifying a failure error message. Use in conjuntion with the default Loose.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify(
    Expression<Action<T>> expression,
    Times times,
    string failMessage
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Action <(Of <(<' T >)>)>>)>)>
Expression to verify.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.
failMessage
Type: System..::..String
Message to show if verification fails.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


Verify(TResult) Method (Expression(Func), Boolean, T)

Mock<(Of <(<'T>)>)>..::..Verify<(Of <(<'TResult>)>)> Method (Expression<(Of <(<'Func>)>)>, Boolean, T)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean,`0)"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void Verify<TResult>(
    Expression<Func> expression,
    bool times,
    T failMessage
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
times
Type: System..::..Boolean
failMessage
Type: T

Type Parameters

TResult

See Also

Mock<(Of <(<'T>)>)> Class
Verify Overload
Moq Namespace


VerifyGet Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..VerifyGet Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
 | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
Public method | VerifyGet<(Of <<'(TProperty>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) |

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


VerifyGet(TProperty) Method (Expression(Func))

Mock<(Of <(<'T>)>)>..::..VerifyGet<(Of <(<'TProperty>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifyGet<TProperty>(
    Expression<Func> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TProperty

See Also

Mock<(Of <(<'T>)>)> Class
VerifyGet Overload
Moq Namespace


VerifyGet(TProperty) Method (Expression(Func), Boolean)

Mock<(Of <(<'T>)>)>..::..VerifyGet<(Of <(<'TProperty>)>)> Method (Expression<(Of <(<'Func>)>)>, Boolean)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]

Namespace: Moq
Assemblies: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)
Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifyGet<TProperty>(
    Expression<Func> expression,
    bool failMessage
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
failMessage
Type: System..::..Boolean

Type Parameters

TProperty

See Also

Mock<(Of <(<'T>)>)> Class
VerifyGet Overload
Moq Namespace


VerifyGet(TProperty) Method (Expression(Func), Boolean, T)

Mock<(Of <(<'T>)>)>..::..VerifyGet<(Of <(<'TProperty>)>)> Method (Expression<(Of <(<'Func>)>)>, Boolean, T)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func`2},System.Boolean,`0)"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifyGet<TProperty>(
    Expression<Func> expression,
    bool times,
    T failMessage
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
times
Type: System..::..Boolean
failMessage
Type: T

Type Parameters

TProperty

See Also

Mock<(Of <(<'T>)>)> Class
VerifyGet Overload
Moq Namespace


VerifySet Method

[image]

Moq
Mock<(Of <(<'T>)>)>..::..VerifySet Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

Overload List

 | Name | Description
Public method | VerifySet(Action<(Of <<'(T>)>>)) | Verifies that a property was set on the mock.
Public method | VerifySet(Action<(Of <<'(T>)>>), Times) | Verifies that a property was set on the mock.
Public method | VerifySet(Action<(Of <<'(T>)>>), String) | Verifies that a property was set on the mock, specifying a failure message.
Public method | VerifySet(Action<(Of <<'(T>)>>), Times, String) | Verifies that a property was set on the mock, specifying a failure message.

See Also

Mock<(Of <(<'T>)>)> Class
Mock<(Of <(<'T>)>)> Members
Moq Namespace


VerifySet Method (Action(T))

Mock<(Of <(<'T>)>)>..::..VerifySet Method (Action<(Of <(<'T>)>)>)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Verifies that a property was set on the mock.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifySet(
    Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
Expression to verify.

Examples

This example assumes that the mock has been used, and later we want to verify that a given property was set on it:
CopyC#
var mock = new Mock<IWarehouse>();
// exercise mock
//...
// Will throw if the test code didn't set the IsClosed property.
mock.VerifySet(warehouse => warehouse.IsClosed = true);

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not performed on the mock.

See Also

Mock<(Of <(<'T>)>)> Class
VerifySet Overload
Moq Namespace


VerifySet Method (Action(T), Times)

Mock<(Of <(<'T>)>)>..::..VerifySet Method (Action<(Of <(<'T>)>)>, Times)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Verifies that a property was set on the mock.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifySet(
    Action<T> setterExpression,
    Times times
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
Expression to verify.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

Mock<(Of <(<'T>)>)> Class
VerifySet Overload
Moq Namespace


VerifySet Method (Action(T), String)

Mock<(Of <(<'T>)>)>..::..VerifySet Method (Action<(Of <(<'T>)>)>, String)
Mock<(Of <(<'T>)>)> Class Example See Also Send Feedback
Verifies that a property was set on the mock, specifying a failure message.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifySet(
    Action<T> setterExpression,
    string failMessage
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
Expression to verify.
failMessage
Type: System..::..String
Message to show if verification fails.

Examples

This example assumes that the mock has been used, and later we want to verify that a given property was set on it:
CopyC#
var mock = new Mock<IWarehouse>();
// exercise mock
//...
// Will throw if the test code didn't set the IsClosed property.
mock.VerifySet(warehouse => warehouse.IsClosed = true, "Warehouse should always be closed after the action");

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not performed on the mock.

See Also

Mock<(Of <(<'T>)>)> Class
VerifySet Overload
Moq Namespace


VerifySet Method (Action(T), Times, String)

Mock<(Of <(<'T>)>)>..::..VerifySet Method (Action<(Of <(<'T>)>)>, Times, String)
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Verifies that a property was set on the mock, specifying a failure message.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifySet(
    Action<T> setterExpression,
    Times times,
    string failMessage
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
Expression to verify.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.
failMessage
Type: System..::..String
Message to show if verification fails.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

Mock<(Of <(<'T>)>)> Class
VerifySet Overload
Moq Namespace


When Method

Mock<(Of <(<'T>)>)>..::..When Method
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mock`1.When(System.Func`1)"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public ISetupConditionResult<T> When(
    Func condition
)

Parameters

condition
Type: System..::..Func<(Of <(<'TResult>)>)>

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


Mock(T) Properties

[image]

Moq
Mock<(Of <(<'T>)>)> Properties
Mock<(Of <(<'T>)>)> Class See Also Send Feedback

The Mock<(Of <(<'T>)>)> type exposes the following members.

Properties

 | Name | Description
Public property | Behavior | Behavior of the mock, according to the value set in the constructor. (Inherited from Mock.)
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic). (Inherited from Mock.)
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks. (Inherited from Mock.)
Public property | Object | Exposes the mocked object instance.

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


Object Property

Mock<(Of <(<'T>)>)>..::..Object Property
Mock<(Of <(<'T>)>)> Class See Also Send Feedback
Exposes the mocked object instance.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual T Object { get; }

See Also

Mock<(Of <(<'T>)>)> Class
Moq Namespace


MockBehavior Enumeration

MockBehavior Enumeration
See Also Send Feedback
Options to customize the behavior of the mock.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public enum MockBehavior

Members

Member name | Description
Strict |
Loose |
Default |

See Also

Moq Namespace


MockException Class

MockException Class
Members See Also Send Feedback
Exception thrown by mocks when setups are not matched, the mock is not properly setup, etc.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[SerializableAttribute]
public class MockException : Exception

Remarks

A distinct exception type is provided so that exceptions thrown by the mock can be differentiated in tests that expect other exceptions to be thrown (i.e. ArgumentException).

Richer exception hierarchy/types are not provided as tests typically should not catch or expect exceptions from the mocks. These are typically the result of changes in the tested class or its collaborators implementation, and result in fixes in the mock setup so that they dissapear and allow the test to pass.

Inheritance Hierarchy

System..::..Object
System..::..Exception
Moq..::..MockException

See Also

MockException Members
Moq Namespace


MockException Members

[image]

Moq
MockException Members
MockException Class Constructors Methods See Also Send Feedback

The MockException type exposes the following members.

Constructors

 | Name | Description
Protected method | MockException | Supports the serialization infrastructure.

Methods

 | Name | Description
Public method | GetObjectData | Supports the serialization infrastructure. (Overrides Exception..::..GetObjectData(SerializationInfo, StreamingContext).)

See Also

MockException Class
Moq Namespace


MockException Constructor

MockException Constructor
MockException Class See Also Send Feedback
Supports the serialization infrastructure.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected MockException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::..SerializationInfo
Serialization information.
context
Type: System.Runtime.Serialization..::..StreamingContext
Streaming context.

See Also

MockException Class
Moq Namespace


MockException Methods

[image]

Moq
MockException Methods
MockException Class See Also Send Feedback

The MockException type exposes the following members.

Methods

 | Name | Description
Public method | GetObjectData | Supports the serialization infrastructure. (Overrides Exception..::..GetObjectData(SerializationInfo, StreamingContext).)

See Also

MockException Class
Moq Namespace


GetObjectData Method

MockException..::..GetObjectData Method
MockException Class See Also Send Feedback
Supports the serialization infrastructure.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::..SerializationInfo
Serialization information.
context
Type: System.Runtime.Serialization..::..StreamingContext
Streaming context.

Implements

ISerializable..::..GetObjectData(SerializationInfo, StreamingContext)
_Exception..::..GetObjectData(SerializationInfo, StreamingContext)

See Also

MockException Class
Moq Namespace


MockExtensions Class

MockExtensions Class
Members See Also Send Feedback
Provides additional methods on mocks.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class MockExtensions

Inheritance Hierarchy

System..::..Object
Moq..::..MockExtensions

See Also

MockExtensions Members
Moq Namespace


MockExtensions Members

[image]

Moq
MockExtensions Members
MockExtensions Class Methods See Also Send Feedback

The MockExtensions type exposes the following members.

Methods

Name | Description
SetupSet<(Of <<'(T, TProperty>)>>) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) | Obsolete.

See Also

MockExtensions Class
Moq Namespace


MockExtensions Methods

[image]

Moq
MockExtensions Methods
MockExtensions Class See Also Send Feedback

The MockExtensions type exposes the following members.

Methods

Name | Description
SetupSet<(Of <<'(T, TProperty>)>>) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) | Obsolete.

See Also

MockExtensions Class
Moq Namespace


SetupSet(T, TProperty) Method

MockExtensions..::..SetupSet<(Of <(<'T, TProperty>)>)> Method
MockExtensions Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.MockExtensions.SetupSet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("Replaced by SetupSet(Action)")]
public static ISetupSetter<T, TProperty> SetupSet<T, TProperty>(
    this Mock<T> mock,
    Expression<Func> expression
)
where T : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'T>)>)>
expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T
TProperty

See Also

MockExtensions Class
Moq Namespace


VerifySet Method

[image]

Moq
MockExtensions..::..VerifySet Method
MockExtensions Class See Also Send Feedback

Overload List

Name | Description
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) | Obsolete.
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean) |
VerifySet<(Of <<'(T, TProperty>)>>)(Mock<(Of <<'(T>)>>), Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>), Boolean, T) | Obsolete.

See Also

MockExtensions Class
MockExtensions Members
Moq Namespace


VerifySet(T, TProperty) Method (Mock(T), Expression(Func))

MockExtensions..::..VerifySet<(Of <(<'T, TProperty>)>)> Method (Mock<(Of <(<'T>)>)>, Expression<(Of <(<'Func>)>)>)
MockExtensions Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("Replaced by VerifySet(Action)")]
public static void VerifySet<T, TProperty>(
    this Mock<T> mock,
    Expression<Func> expression
)
where T : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'T>)>)>
expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T
TProperty

See Also

MockExtensions Class
VerifySet Overload
Moq Namespace


VerifySet(T, TProperty) Method (Mock(T), Expression(Func), Boolean)

MockExtensions..::..VerifySet<(Of <(<'T, TProperty>)>)> Method (Mock<(Of <(<'T>)>)>, Expression<(Of <(<'Func>)>)>, Boolean)
MockExtensions Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2},System.Boolean)"]

Namespace: Moq
Assemblies: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)
Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("Replaced by  VerifySet(Action, Times)")]
public static void VerifySet<T, TProperty>(
    this Mock<T> mock,
    Expression<Func> expression,
    bool times
)
where T : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'T>)>)>
expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
times
Type: System..::..Boolean

Type Parameters

T
TProperty

See Also

MockExtensions Class
VerifySet Overload
Moq Namespace


VerifySet(T, TProperty) Method (Mock(T), Expression(Func), Boolean, T)

MockExtensions..::..VerifySet<(Of <(<'T, TProperty>)>)> Method (Mock<(Of <(<'T>)>)>, Expression<(Of <(<'Func>)>)>, Boolean, T)
MockExtensions Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2},System.Boolean,``0)"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("Replaced by  VerifySet(Action, Times, string)")]
public static void VerifySet<T, TProperty>(
    this Mock<T> mock,
    Expression<Func> expression,
    bool times,
    T failMessage
)
where T : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'T>)>)>
expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>
times
Type: System..::..Boolean
failMessage
Type: T

Type Parameters

T
TProperty

See Also

MockExtensions Class
VerifySet Overload
Moq Namespace


MockFactory Class

MockFactory Class
Members Example See Also Send Feedback
Utility factory class to use to construct multiple mocks when consistent verification is desired for all of them.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("This class has been renamed to MockRepository. MockFactory will be retired in v5.",
    false)]
public class MockFactory

Remarks

If multiple mocks will be created during a test, passing the desired MockBehavior (if different than the Default or the one passed to the factory constructor) and later verifying each mock can become repetitive and tedious.

This factory class helps in that scenario by providing a simplified creation of multiple mocks with a default MockBehavior (unless overriden by calling Create<(Of <<'(T>)>>)(MockBehavior)) and posterior verification.

Examples

The following is a straightforward example on how to create and automatically verify strict mocks using a MockFactory:
CopyC#
var factory = new MockFactory(MockBehavior.Strict);

var foo = factory.Create<IFoo>();
var bar = factory.Create<IBar>();

// no need to call Verifiable() on the setup
// as we'll be validating all of them anyway.
foo.Setup(f => f.Do());
bar.Setup(b => b.Redo());

// exercise the mocks here

factory.VerifyAll();
// At this point all setups are already checked
// and an optional MockException might be thrown.
// Note also that because the mocks are strict, any invocation
// that doesn't have a matching setup will also throw a MockException.
 The following examples shows how to setup the factory to create loose mocks and later verify only verifiable setups:
CopyC#
var factory = new MockFactory(MockBehavior.Loose);

var foo = factory.Create<IFoo>();
var bar = factory.Create<IBar>();

// this setup will be verified when we verify the factory
foo.Setup(f => f.Do()).Verifiable();

// this setup will NOT be verified
foo.Setup(f => f.Calculate());

// this setup will be verified when we verify the factory
bar.Setup(b => b.Redo()).Verifiable();

// exercise the mocks here
// note that because the mocks are Loose, members
// called in the interfaces for which no matching
// setups exist will NOT throw exceptions,
// and will rather return default values.

factory.Verify();
// At this point verifiable setups are already checked
// and an optional MockException might be thrown.
 The following examples shows how to setup the factory with a default strict behavior, overriding that default for a specific mock:
CopyC#
var factory = new MockFactory(MockBehavior.Strict);

// this particular one we want loose
var foo = factory.Create<IFoo>(MockBehavior.Loose);
var bar = factory.Create<IBar>();

// specify setups

// exercise the mocks here

factory.Verify();

Inheritance Hierarchy

System..::..Object
Moq..::..MockFactory
Moq..::..MockRepository

See Also

MockFactory Members
Moq Namespace
Moq..::..MockBehavior


MockFactory Members

[image]

Moq
MockFactory Members
MockFactory Class Constructors Methods Properties See Also Send Feedback

The MockFactory type exposes the following members.

Constructors

 | Name | Description
Public method | MockFactory | Initializes the factory with the given defaultBehavior for newly created mocks from the factory.

Methods

 | Name | Description
Public method | Create<(Of <<'(T>)>>)()()()() | Creates a new mock with the default MockBehavior specified at factory construction time.
Public method | Create<(Of <<'(T>)>>)(array<Object>[]()[][]) | Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class.
Public method | Create<(Of <<'(T>)>>)(MockBehavior) | Creates a new mock with the given behavior.
Public method | Create<(Of <<'(T>)>>)(MockBehavior, array<Object>[]()[][]) | Creates a new mock with the given behavior and with the the given constructor arguments for the class.
Protected method | CreateMock<(Of <<'(T>)>>) | Implements creation of a new mock within the factory.
Public method | Verify | Verifies all verifiable expectations on all mocks created by this factory.
Public method | VerifyAll | Verifies all verifiable expectations on all mocks created by this factory.
Protected method | VerifyMocks | Invokes verifyAction for each mock in Mocks, and accumulates the resulting MockVerificationException that might be thrown from the action.

Properties

 | Name | Description
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic).
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks.
Protected property | Mocks | Gets the mocks that have been created by this factory and that will get verified together.

See Also

MockFactory Class
Moq Namespace


MockFactory Constructor

MockFactory Constructor
MockFactory Class See Also Send Feedback
Initializes the factory with the given defaultBehavior for newly created mocks from the factory.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public MockFactory(
    MockBehavior defaultBehavior
)

Parameters

defaultBehavior
Type: Moq..::..MockBehavior
The behavior to use for mocks created using the Create<(Of <<'(T>)>>)()()()() factory method if not overriden by using the Create<(Of <<'(T>)>>)(MockBehavior) overload.

See Also

MockFactory Class
Moq Namespace


MockFactory Methods

[image]

Moq
MockFactory Methods
MockFactory Class See Also Send Feedback

The MockFactory type exposes the following members.

Methods

 | Name | Description
Public method | Create<(Of <<'(T>)>>)()()()() | Creates a new mock with the default MockBehavior specified at factory construction time.
Public method | Create<(Of <<'(T>)>>)(array<Object>[]()[][]) | Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class.
Public method | Create<(Of <<'(T>)>>)(MockBehavior) | Creates a new mock with the given behavior.
Public method | Create<(Of <<'(T>)>>)(MockBehavior, array<Object>[]()[][]) | Creates a new mock with the given behavior and with the the given constructor arguments for the class.
Protected method | CreateMock<(Of <<'(T>)>>) | Implements creation of a new mock within the factory.
Public method | Verify | Verifies all verifiable expectations on all mocks created by this factory.
Public method | VerifyAll | Verifies all verifiable expectations on all mocks created by this factory.
Protected method | VerifyMocks | Invokes verifyAction for each mock in Mocks, and accumulates the resulting MockVerificationException that might be thrown from the action.

See Also

MockFactory Class
Moq Namespace


Create Method

[image]

Moq
MockFactory..::..Create Method
MockFactory Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Create<(Of <<'(T>)>>)()()()() | Creates a new mock with the default MockBehavior specified at factory construction time.
Public method | Create<(Of <<'(T>)>>)(array<Object>[]()[][]) | Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class.
Public method | Create<(Of <<'(T>)>>)(MockBehavior) | Creates a new mock with the given behavior.
Public method | Create<(Of <<'(T>)>>)(MockBehavior, array<Object>[]()[][]) | Creates a new mock with the given behavior and with the the given constructor arguments for the class.

See Also

MockFactory Class
MockFactory Members
Moq Namespace


Create(T) Method

MockFactory..::..Create<(Of <(<'T>)>)> Method
MockFactory Class Example See Also Send Feedback
Creates a new mock with the default MockBehavior specified at factory construction time.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> Create<T>()
where T : class

Type Parameters

T
Type to mock.

Return Value

A new Mock<(Of <(<'T>)>)>.

Examples

CopyC#
var factory = new MockFactory(MockBehavior.Strict);

var foo = factory.Create<IFoo>();
// use mock on tests

factory.VerifyAll();

See Also

MockFactory Class
Create Overload
Moq Namespace


Create(T) Method (Object[])

MockFactory..::..Create<(Of <(<'T>)>)> Method (array<Object>[]()[][])
MockFactory Class Example See Also Send Feedback
Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> Create<T>(
    params Object[] args
)
where T : class

Parameters

args
Type: array< System..::..Object >[]()[][]
Constructor arguments for mocked classes.

Type Parameters

T
Type to mock.

Return Value

A new Mock<(Of <(<'T>)>)>.

Remarks

The mock will try to find the best match constructor given the constructor arguments, and invoke that to initialize the instance. This applies only to classes, not interfaces.

Examples

CopyC#
var factory = new MockFactory(MockBehavior.Default);

var mock = factory.Create<MyBase>("Foo", 25, true);
// use mock on tests

factory.Verify();

See Also

MockFactory Class
Create Overload
Moq Namespace


Create(T) Method (MockBehavior)

MockFactory..::..Create<(Of <(<'T>)>)> Method (MockBehavior)
MockFactory Class Example See Also Send Feedback
Creates a new mock with the given behavior.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> Create<T>(
    MockBehavior behavior
)
where T : class

Parameters

behavior
Type: Moq..::..MockBehavior
Behavior to use for the mock, which overrides the default behavior specified at factory construction time.

Type Parameters

T
Type to mock.

Return Value

A new Mock<(Of <(<'T>)>)>.

Examples

The following example shows how to create a mock with a different behavior to that specified as the default for the factory:
CopyC#
var factory = new MockFactory(MockBehavior.Strict);

var foo = factory.Create<IFoo>(MockBehavior.Loose);

See Also

MockFactory Class
Create Overload
Moq Namespace


Create(T) Method (MockBehavior, Object[])

MockFactory..::..Create<(Of <(<'T>)>)> Method (MockBehavior, array<Object>[]()[][])
MockFactory Class Example See Also Send Feedback
Creates a new mock with the given behavior and with the the given constructor arguments for the class.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public Mock<T> Create<T>(
    MockBehavior behavior,
    params Object[] args
)
where T : class

Parameters

behavior
Type: Moq..::..MockBehavior
Behavior to use for the mock, which overrides the default behavior specified at factory construction time.
args
Type: array< System..::..Object >[]()[][]
Constructor arguments for mocked classes.

Type Parameters

T
Type to mock.

Return Value

A new Mock<(Of <(<'T>)>)>.

Remarks

The mock will try to find the best match constructor given the constructor arguments, and invoke that to initialize the instance. This applies only to classes, not interfaces.

Examples

The following example shows how to create a mock with a different behavior to that specified as the default for the factory, passing constructor arguments:
CopyC#
var factory = new MockFactory(MockBehavior.Default);

var mock = factory.Create<MyBase>(MockBehavior.Strict, "Foo", 25, true);

See Also

MockFactory Class
Create Overload
Moq Namespace


CreateMock(T) Method

MockFactory..::..CreateMock<(Of <(<'T>)>)> Method
MockFactory Class See Also Send Feedback
Implements creation of a new mock within the factory.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected virtual Mock<T> CreateMock<T>(
    MockBehavior behavior,
    Object[] args
)
where T : class

Parameters

behavior
Type: Moq..::..MockBehavior
The behavior for the new mock.
args
Type: array< System..::..Object >[]()[][]
Optional arguments for the construction of the mock.

Type Parameters

T
Type to mock.

See Also

MockFactory Class
Moq Namespace


Verify Method

MockFactory..::..Verify Method
MockFactory Class See Also Send Feedback
Verifies all verifiable expectations on all mocks created by this factory.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual void Verify()

Exceptions

Exception | Condition
Moq..::..MockException | One or more mocks had expectations that were not satisfied.

See Also

MockFactory Class
Moq Namespace
Mock..::..Verify()()()()


VerifyAll Method

MockFactory..::..VerifyAll Method
MockFactory Class See Also Send Feedback
Verifies all verifiable expectations on all mocks created by this factory.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public virtual void VerifyAll()

Exceptions

Exception | Condition
Moq..::..MockException | One or more mocks had expectations that were not satisfied.

See Also

MockFactory Class
Moq Namespace
Mock..::..Verify()()()()


VerifyMocks Method

MockFactory..::..VerifyMocks Method
MockFactory Class See Also Send Feedback
Invokes verifyAction for each mock in Mocks, and accumulates the resulting MockVerificationException that might be thrown from the action.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected virtual void VerifyMocks(
    Action<Mock> verifyAction
)

Parameters

verifyAction
Type: System..::..Action <(Of <(<' Mock >)>)>
The action to execute against each mock.

See Also

MockFactory Class
Moq Namespace


MockFactory Properties

[image]

Moq
MockFactory Properties
MockFactory Class See Also Send Feedback

The MockFactory type exposes the following members.

Properties

 | Name | Description
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic).
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks.
Protected property | Mocks | Gets the mocks that have been created by this factory and that will get verified together.

See Also

MockFactory Class
Moq Namespace


CallBase Property

MockFactory..::..CallBase Property
MockFactory Class See Also Send Feedback
Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic).

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public bool CallBase { get; set; }

See Also

MockFactory Class
Moq Namespace


DefaultValue Property

MockFactory..::..DefaultValue Property
MockFactory Class See Also Send Feedback
Specifies the behavior to use when returning default values for unexpected invocations on loose mocks.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public DefaultValue DefaultValue { get; set; }

See Also

MockFactory Class
Moq Namespace


Mocks Property

MockFactory..::..Mocks Property
MockFactory Class See Also Send Feedback
Gets the mocks that have been created by this factory and that will get verified together.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
protected internal IEnumerable<Mock> Mocks { get; }

See Also

MockFactory Class
Moq Namespace


MockRepository Class

MockRepository Class
Members Example See Also Send Feedback
Utility repository class to use to construct multiple mocks when consistent verification is desired for all of them.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public class MockRepository : MockFactory

Remarks

If multiple mocks will be created during a test, passing the desired MockBehavior (if different than the Default or the one passed to the repository constructor) and later verifying each mock can become repetitive and tedious.

This repository class helps in that scenario by providing a simplified creation of multiple mocks with a default MockBehavior (unless overriden by calling Create<(Of <<'(T>)>>)(MockBehavior)) and posterior verification.

Examples

The following is a straightforward example on how to create and automatically verify strict mocks using a MockRepository:
CopyC#
var repository = new MockRepository(MockBehavior.Strict);

var foo = repository.Create<IFoo>();
var bar = repository.Create<IBar>();

// no need to call Verifiable() on the setup
// as we'll be validating all of them anyway.
foo.Setup(f => f.Do());
bar.Setup(b => b.Redo());

// exercise the mocks here

repository.VerifyAll();
// At this point all setups are already checked
// and an optional MockException might be thrown.
// Note also that because the mocks are strict, any invocation
// that doesn't have a matching setup will also throw a MockException.
 The following examples shows how to setup the repository to create loose mocks and later verify only verifiable setups:
CopyC#
var repository = new MockRepository(MockBehavior.Loose);

var foo = repository.Create<IFoo>();
var bar = repository.Create<IBar>();

// this setup will be verified when we verify the repository
foo.Setup(f => f.Do()).Verifiable();

// this setup will NOT be verified
foo.Setup(f => f.Calculate());

// this setup will be verified when we verify the repository
bar.Setup(b => b.Redo()).Verifiable();

// exercise the mocks here
// note that because the mocks are Loose, members
// called in the interfaces for which no matching
// setups exist will NOT throw exceptions,
// and will rather return default values.

repository.Verify();
// At this point verifiable setups are already checked
// and an optional MockException might be thrown.
 The following examples shows how to setup the repository with a default strict behavior, overriding that default for a specific mock:
CopyC#
var repository = new MockRepository(MockBehavior.Strict);

// this particular one we want loose
var foo = repository.Create<IFoo>(MockBehavior.Loose);
var bar = repository.Create<IBar>();

// specify setups

// exercise the mocks here

repository.Verify();

Inheritance Hierarchy

System..::..Object
Moq..::..MockFactory
Moq..::..MockRepository

See Also

MockRepository Members
Moq Namespace
Moq..::..MockBehavior


MockRepository Members

[image]

Moq
MockRepository Members
MockRepository Class Constructors Methods Properties See Also Send Feedback

The MockRepository type exposes the following members.

Constructors

 | Name | Description
Public method | MockRepository | Initializes the repository with the given defaultBehavior for newly created mocks from the repository.

Methods

 | Name | Description
Public method | Create<(Of <<'(T>)>>)()()()() | Creates a new mock with the default MockBehavior specified at factory construction time. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(array<Object>[]()[][]) | Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(MockBehavior) | Creates a new mock with the given behavior. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(MockBehavior, array<Object>[]()[][]) | Creates a new mock with the given behavior and with the the given constructor arguments for the class. (Inherited from MockFactory.)
Protected method | CreateMock<(Of <<'(T>)>>) | Implements creation of a new mock within the factory. (Inherited from MockFactory.)
Public method | Of<(Of <<'(T>)>>)()()()() | Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.
Public method | Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | OneOf<(Of <<'(T>)>>)()()()() | Creates an mock object of the indicated type.
Public method | OneOf<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | Verify | Verifies all verifiable expectations on all mocks created by this factory. (Inherited from MockFactory.)
Public method | VerifyAll | Verifies all verifiable expectations on all mocks created by this factory. (Inherited from MockFactory.)
Protected method | VerifyMocks | Invokes verifyAction for each mock in Mocks, and accumulates the resulting MockVerificationException that might be thrown from the action. (Inherited from MockFactory.)

Properties

 | Name | Description
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic). (Inherited from MockFactory.)
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks. (Inherited from MockFactory.)
Protected property | Mocks | Gets the mocks that have been created by this factory and that will get verified together. (Inherited from MockFactory.)

See Also

MockRepository Class
Moq Namespace


MockRepository Constructor

MockRepository Constructor
MockRepository Class See Also Send Feedback
Initializes the repository with the given defaultBehavior for newly created mocks from the repository.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public MockRepository(
    MockBehavior defaultBehavior
)

Parameters

defaultBehavior
Type: Moq..::..MockBehavior
The behavior to use for mocks created using the Create<(Of <<'(T>)>>)()()()() repository method if not overriden by using the Create<(Of <<'(T>)>>)(MockBehavior) overload.

See Also

MockRepository Class
Moq Namespace


MockRepository Methods

[image]

Moq
MockRepository Methods
MockRepository Class See Also Send Feedback

The MockRepository type exposes the following members.

Methods

 | Name | Description
Public method | Create<(Of <<'(T>)>>)()()()() | Creates a new mock with the default MockBehavior specified at factory construction time. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(array<Object>[]()[][]) | Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(MockBehavior) | Creates a new mock with the given behavior. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(MockBehavior, array<Object>[]()[][]) | Creates a new mock with the given behavior and with the the given constructor arguments for the class. (Inherited from MockFactory.)
Protected method | CreateMock<(Of <<'(T>)>>) | Implements creation of a new mock within the factory. (Inherited from MockFactory.)
Public method | Of<(Of <<'(T>)>>)()()()() | Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.
Public method | Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | OneOf<(Of <<'(T>)>>)()()()() | Creates an mock object of the indicated type.
Public method | OneOf<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | Verify | Verifies all verifiable expectations on all mocks created by this factory. (Inherited from MockFactory.)
Public method | VerifyAll | Verifies all verifiable expectations on all mocks created by this factory. (Inherited from MockFactory.)
Protected method | VerifyMocks | Invokes verifyAction for each mock in Mocks, and accumulates the resulting MockVerificationException that might be thrown from the action. (Inherited from MockFactory.)

See Also

MockRepository Class
Moq Namespace


Create Method

[image]

Moq
MockRepository..::..Create Method
MockRepository Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Create<(Of <<'(T>)>>)()()()() | Creates a new mock with the default MockBehavior specified at factory construction time. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(array<Object>[]()[][]) | Creates a new mock with the default MockBehavior specified at factory construction time and with the the given constructor arguments for the class. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(MockBehavior) | Creates a new mock with the given behavior. (Inherited from MockFactory.)
Public method | Create<(Of <<'(T>)>>)(MockBehavior, array<Object>[]()[][]) | Creates a new mock with the given behavior and with the the given constructor arguments for the class. (Inherited from MockFactory.)

See Also

MockRepository Class
MockRepository Members
Moq Namespace


Of Method

[image]

Moq
MockRepository..::..Of Method
MockRepository Class See Also Send Feedback

Overload List

 | Name | Description
Public method | Of<(Of <<'(T>)>>)()()()() | Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.
Public method | Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |

See Also

MockRepository Class
MockRepository Members
Moq Namespace


Of(T) Method

MockRepository..::..Of<(Of <(<'T>)>)> Method
MockRepository Class See Also Send Feedback
Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public IQueryable<T> Of<T>()
where T : class

Type Parameters

T
The type of the mocked object to query.

See Also

MockRepository Class
Of Overload
Moq Namespace


Of(T) Method (Expression(Func))

MockRepository..::..Of<(Of <(<'T>)>)> Method (Expression<(Of <(<'Func>)>)>)
MockRepository Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.MockRepository.Of``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public IQueryable<T> Of<T>(
    Expression<Func> specification
)
where T : class

Parameters

specification
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T

See Also

MockRepository Class
Of Overload
Moq Namespace


OneOf Method

[image]

Moq
MockRepository..::..OneOf Method
MockRepository Class See Also Send Feedback

Overload List

 | Name | Description
Public method | OneOf<(Of <<'(T>)>>)()()()() | Creates an mock object of the indicated type.
Public method | OneOf<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |

See Also

MockRepository Class
MockRepository Members
Moq Namespace


OneOf(T) Method

MockRepository..::..OneOf<(Of <(<'T>)>)> Method
MockRepository Class See Also Send Feedback
Creates an mock object of the indicated type.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public T OneOf<T>()
where T : class

Type Parameters

T
The type of the mocked object.

Return Value

The mocked object created.

See Also

MockRepository Class
OneOf Overload
Moq Namespace


OneOf(T) Method (Expression(Func))

MockRepository..::..OneOf<(Of <(<'T>)>)> Method (Expression<(Of <(<'Func>)>)>)
MockRepository Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.MockRepository.OneOf``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public T OneOf<T>(
    Expression<Func> specification
)
where T : class

Parameters

specification
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T

See Also

MockRepository Class
OneOf Overload
Moq Namespace


MockRepository Properties

[image]

Moq
MockRepository Properties
MockRepository Class See Also Send Feedback

The MockRepository type exposes the following members.

Properties

 | Name | Description
Public property | CallBase | Whether the base member virtual implementation will be called for mocked classes if no setup is matched. Defaults to falseFalsefalsefalse (False in Visual Basic). (Inherited from MockFactory.)
Public property | DefaultValue | Specifies the behavior to use when returning default values for unexpected invocations on loose mocks. (Inherited from MockFactory.)
Protected property | Mocks | Gets the mocks that have been created by this factory and that will get verified together. (Inherited from MockFactory.)

See Also

MockRepository Class
Moq Namespace


Mocks Class

Mocks Class
Members See Also Send Feedback
Allows querying the universe of mocks for those that behave according to the LINQ query specification.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class Mocks

Inheritance Hierarchy

System..::..Object
Moq..::..Mocks

See Also

Mocks Members
Moq Namespace


Mocks Members

[image]

Moq
Mocks Members
Mocks Class Methods See Also Send Feedback

Methods

Name | Description
Of<(Of <<'(T>)>>)()()()() | Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.
Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
OneOf<(Of <<'(T>)>>)()()()() | Obsolete. Creates an mock object of the indicated type.
OneOf<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Obsolete.

See Also

Mocks Class
Moq Namespace


Mocks Methods

[image]

Moq
Mocks Methods
Mocks Class See Also Send Feedback

Methods

Name | Description
Of<(Of <<'(T>)>>)()()()() | Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.
Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
OneOf<(Of <<'(T>)>>)()()()() | Obsolete. Creates an mock object of the indicated type.
OneOf<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Obsolete.

See Also

Mocks Class
Moq Namespace


Of Method

[image]

Moq
Mocks..::..Of Method
Mocks Class See Also Send Feedback

Overload List

Name | Description
Of<(Of <<'(T>)>>)()()()() | Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.
Of<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |

See Also

Mocks Class
Mocks Members
Moq Namespace


Of(T) Method

Mocks..::..Of<(Of <(<'T>)>)> Method
Mocks Class See Also Send Feedback
Access the universe of mocks of the given type, to retrieve those that behave according to the LINQ query specification.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static IQueryable<T> Of<T>()
where T : class

Type Parameters

T
The type of the mocked object to query.

See Also

Mocks Class
Of Overload
Moq Namespace


Of(T) Method (Expression(Func))

Mocks..::..Of<(Of <(<'T>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mocks Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mocks.Of``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static IQueryable<T> Of<T>(
    Expression<Func> specification
)
where T : class

Parameters

specification
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T

See Also

Mocks Class
Of Overload
Moq Namespace


OneOf Method

[image]

Moq
Mocks..::..OneOf Method
Mocks Class See Also Send Feedback

Overload List

Name | Description
OneOf<(Of <<'(T>)>>)()()()() | Obsolete. Creates an mock object of the indicated type.
OneOf<(Of <<'(T>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) | Obsolete.

See Also

Mocks Class
Mocks Members
Moq Namespace


OneOf(T) Method

Mocks..::..OneOf<(Of <(<'T>)>)> Method
Mocks Class See Also Send Feedback
Creates an mock object of the indicated type.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("Moved to Mock.Of<T>, as it's a single one, so no reason to be on Mocks.",
    true)]
public static T OneOf<T>()
where T : class

Type Parameters

T
The type of the mocked object.

Return Value

The mocked object created.

See Also

Mocks Class
OneOf Overload
Moq Namespace


OneOf(T) Method (Expression(Func))

Mocks..::..OneOf<(Of <(<'T>)>)> Method (Expression<(Of <(<'Func>)>)>)
Mocks Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Mocks.OneOf``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[ObsoleteAttribute("Moved to Mock.Of<T>, as it's a single one, so no reason to be on Mocks.",
    true)]
public static T OneOf<T>(
    Expression<Func> specification
)
where T : class

Parameters

specification
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

T

See Also

Mocks Class
OneOf Overload
Moq Namespace


MockSequence Class

MockSequence Class
Members See Also Send Feedback
Helper class to setup a full trace between many mocks

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public class MockSequence

Inheritance Hierarchy

System..::..Object
Moq..::..MockSequence

See Also

MockSequence Members
Moq Namespace


MockSequence Members

[image]

Moq
MockSequence Members
MockSequence Class Constructors Properties See Also Send Feedback

The MockSequence type exposes the following members.

Constructors

 | Name | Description
Public method | MockSequence | Initialize a trace setup

Properties

 | Name | Description
Public property | Cyclic | Allow sequence to be repeated

See Also

MockSequence Class
Moq Namespace


MockSequence Constructor

MockSequence Constructor
MockSequence Class See Also Send Feedback
Initialize a trace setup

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public MockSequence()

See Also

MockSequence Class
Moq Namespace


MockSequence Properties

[image]

Moq
MockSequence Properties
MockSequence Class See Also Send Feedback

The MockSequence type exposes the following members.

Properties

 | Name | Description
Public property | Cyclic | Allow sequence to be repeated

See Also

MockSequence Class
Moq Namespace


Cyclic Property

MockSequence..::..Cyclic Property
MockSequence Class See Also Send Feedback
Allow sequence to be repeated

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public bool Cyclic { get; set; }

See Also

MockSequence Class
Moq Namespace


MockSequenceHelper Class

MockSequenceHelper Class
Members See Also Send Feedback
define nice api

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class MockSequenceHelper

Inheritance Hierarchy

System..::..Object
Moq..::..MockSequenceHelper

See Also

MockSequenceHelper Members
Moq Namespace


MockSequenceHelper Members

[image]

Moq
MockSequenceHelper Members
MockSequenceHelper Class Methods See Also Send Feedback

The MockSequenceHelper type exposes the following members.

Methods

Name | Description
InSequence<(Of <<'(TMock>)>>) | Perform an expectation in the trace.

See Also

MockSequenceHelper Class
Moq Namespace


MockSequenceHelper Methods

[image]

Moq
MockSequenceHelper Methods
MockSequenceHelper Class See Also Send Feedback

The MockSequenceHelper type exposes the following members.

Methods

Name | Description
InSequence<(Of <<'(TMock>)>>) | Perform an expectation in the trace.

See Also

MockSequenceHelper Class
Moq Namespace


InSequence(TMock) Method

MockSequenceHelper..::..InSequence<(Of <(<'TMock>)>)> Method
MockSequenceHelper Class See Also Send Feedback
Perform an expectation in the trace.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static ISetupConditionResult<TMock> InSequence<TMock>(
    this Mock<TMock> mock,
    MockSequence sequence
)
where TMock : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'TMock>)>)>
sequence
Type: Moq..::..MockSequence

Type Parameters

TMock

See Also

MockSequenceHelper Class
Moq Namespace


Range Enumeration

Range Enumeration
See Also Send Feedback
Kind of range to use in a filter specified through IsInRange<(Of <<'(TValue>)>>)(TValue, TValue, Range).

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public enum Range

Members

Member name | Description
Inclusive |
Exclusive |

See Also

Moq Namespace


SequenceExtensions Class

SequenceExtensions Class
Members See Also Send Feedback
Helper for sequencing return values in the same method.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class SequenceExtensions

Inheritance Hierarchy

System..::..Object
Moq..::..SequenceExtensions

See Also

SequenceExtensions Members
Moq Namespace


SequenceExtensions Members

[image]

Moq
SequenceExtensions Members
SequenceExtensions Class Methods See Also Send Feedback

The SequenceExtensions type exposes the following members.

Methods

Name | Description
SetupSequence<(Of <<'(TMock, TResult>)>>) |

See Also

SequenceExtensions Class
Moq Namespace


SequenceExtensions Methods

[image]

Moq
SequenceExtensions Methods
SequenceExtensions Class See Also Send Feedback

The SequenceExtensions type exposes the following members.

Methods

Name | Description
SetupSequence<(Of <<'(TMock, TResult>)>>) |

See Also

SequenceExtensions Class
Moq Namespace


SetupSequence(TMock, TResult) Method

SequenceExtensions..::..SetupSequence<(Of <(<'TMock, TResult>)>)> Method
SequenceExtensions Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.SequenceExtensions.SetupSequence``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static ISetupSequentialResult<TResult> SetupSequence<TMock, TResult>(
    this Mock<TMock> mock,
    Expression<Func> expression
)
where TMock : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'TMock>)>)>
expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TMock
TResult

See Also

SequenceExtensions Class
Moq Namespace


Times Structure

Times Structure
Members See Also Send Feedback
Defines the number of invocations allowed by a mocked method.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public struct Times

See Also

Times Members
Moq Namespace


Times Members

[image]

Moq
Times Members
Times Structure Methods Operators See Also Send Feedback

The Times type exposes the following members.

Methods

 | Name | Description
 | AtLeast | Specifies that a mocked method should be invoked callCount times as minimum.
 | AtLeastOnce | Specifies that a mocked method should be invoked one time as minimum.
 | AtMost | Specifies that a mocked method should be invoked callCount time as maximun.
 | AtMostOnce | Specifies that a mocked method should be invoked one time as maximun.
 | Between | Specifies that a mocked method should be invoked between callCountFrom and callCountTo times.
Public method | Equals | Determines whether the specified Object is equal to this instance. (Overrides ValueType..::..Equals(Object).)
 | Exactly | Specifies that a mocked method should be invoked exactly callCount times.
Public method | GetHashCode | Returns a hash code for this instance. (Overrides ValueType..::..GetHashCode()()()().)
 | Never | Specifies that a mocked method should not be invoked.
 | Once | Specifies that a mocked method should be invoked exactly one time.

Operators

Name | Description
Equality | Determines whether two specified Times objects have the same value.
Inequality | Determines whether two specified Times objects have different values.

See Also

Times Structure
Moq Namespace


Times Methods

[image]

Moq
Times Methods
Times Structure See Also Send Feedback

The Times type exposes the following members.

Methods

 | Name | Description
 | AtLeast | Specifies that a mocked method should be invoked callCount times as minimum.
 | AtLeastOnce | Specifies that a mocked method should be invoked one time as minimum.
 | AtMost | Specifies that a mocked method should be invoked callCount time as maximun.
 | AtMostOnce | Specifies that a mocked method should be invoked one time as maximun.
 | Between | Specifies that a mocked method should be invoked between callCountFrom and callCountTo times.
Public method | Equals | Determines whether the specified Object is equal to this instance. (Overrides ValueType..::..Equals(Object).)
 | Exactly | Specifies that a mocked method should be invoked exactly callCount times.
Public method | GetHashCode | Returns a hash code for this instance. (Overrides ValueType..::..GetHashCode()()()().)
 | Never | Specifies that a mocked method should not be invoked.
 | Once | Specifies that a mocked method should be invoked exactly one time.

See Also

Times Structure
Moq Namespace


AtLeast Method

Times..::..AtLeast Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked callCount times as minimum.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times AtLeast(
    int callCount
)

Parameters

callCount
Type: System..::..Int32
The minimun number of times.

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


AtLeastOnce Method

Times..::..AtLeastOnce Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked one time as minimum.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times AtLeastOnce()

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


AtMost Method

Times..::..AtMost Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked callCount time as maximun.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times AtMost(
    int callCount
)

Parameters

callCount
Type: System..::..Int32
The maximun number of times.

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


AtMostOnce Method

Times..::..AtMostOnce Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked one time as maximun.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times AtMostOnce()

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


Between Method

Times..::..Between Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked between callCountFrom and callCountTo times.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times Between(
    int callCountFrom,
    int callCountTo,
    Range rangeKind
)

Parameters

callCountFrom
Type: System..::..Int32
The minimun number of times.
callCountTo
Type: System..::..Int32
The maximun number of times.
rangeKind
Type: Moq..::..Range
The kind of range. See Range.

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


Equals Method

Times..::..Equals Method
Times Structure See Also Send Feedback
Determines whether the specified Object is equal to this instance.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public override bool Equals(
    Object obj
)

Parameters

obj
Type: System..::..Object
The Object to compare with this instance.

Return Value

true if the specified Object is equal to this instance; otherwise, false.

See Also

Times Structure
Moq Namespace


Exactly Method

Times..::..Exactly Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked exactly callCount times.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times Exactly(
    int callCount
)

Parameters

callCount
Type: System..::..Int32
The times that a method or property can be called.

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


GetHashCode Method

Times..::..GetHashCode Method
Times Structure See Also Send Feedback
Returns a hash code for this instance.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public override int GetHashCode()

Return Value

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

See Also

Times Structure
Moq Namespace


Never Method

Times..::..Never Method
Times Structure See Also Send Feedback
Specifies that a mocked method should not be invoked.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times Never()

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


Once Method

Times..::..Once Method
Times Structure See Also Send Feedback
Specifies that a mocked method should be invoked exactly one time.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Times Once()

Return Value

An object defining the allowed number of invocations.

See Also

Times Structure
Moq Namespace


Times Operators

[image]

Moq
Times Operators
Times Structure See Also Send Feedback

The Times type exposes the following members.

Operators

Name | Description
Equality | Determines whether two specified Times objects have the same value.
Inequality | Determines whether two specified Times objects have different values.

See Also

Times Structure
Moq Namespace


Equality Operator

Times..::..Equality Operator
Times Structure See Also Send Feedback
Determines whether two specified Times objects have the same value.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static bool operator ==(
    Times left,
    Times right
)

Parameters

left
Type: Moq..::..Times
The first Times.
right
Type: Moq..::..Times
The second Times.

Return Value

true if the value of left is the same as the value of right; otherwise, false.

See Also

Times Structure
Moq Namespace


Inequality Operator

Times..::..Inequality Operator
Times Structure See Also Send Feedback
Determines whether two specified Times objects have different values.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static bool operator !=(
    Times left,
    Times right
)

Parameters

left
Type: Moq..::..Times
The first Times.
right
Type: Moq..::..Times
The second Times.

Return Value

true if the value of left is different from the value of right; otherwise, false.

See Also

Times Structure
Moq Namespace


Moq.Language Namespace

Moq.Language Namespace
Send Feedback
This namespace defines the interfaces that contain the methods available in Moq fluent API, such as Setup, Callback, Returns, Throws, etc.

Review the documentation of the available methods on these interfaces for code examples. The way these interfaces are composed, grouped and made visible at different stages during an expectation (i.e. Verifiable is the last "verb" and can't be specified before the Returns) is internal but the API will naturally lead you to the proper way of using it, so don't worry too much about who (and where) exposes these language interfaces. They will show up in Intellisense when it's appropriate.

Do use their documentation to learn about options (especially when there are several overloads available) that may be a better fit for a particular scenario.

Interfaces

 | Interface | Description
Public interface | ICallback | Defines the Callback verb and overloads.
Public interface | ICallback<(Of <(<'TMock, TResult>)>)> | Defines the Callback verb and overloads for callbacks on setups that return a value.
Public interface | ICallbackGetter<(Of <(<'TMock, TProperty>)>)> | Defines the Callback verb for property getter setups.
Public interface | ICallbackSetter<(Of <(<'TProperty>)>)> | Defines the Callback verb for property setter setups.
Public interface | IRaise<(Of <(<'T>)>)> | Defines the Raises verb.
Public interface | IReturns<(Of <(<'TMock, TResult>)>)> | Defines the Returns verb.
Public interface | IReturnsGetter<(Of <(<'TMock, TProperty>)>)> | Defines the Returns verb for property get setups.
Public interface | ISetupConditionResult<(Of <(<'T>)>)> | Implements the fluent API.
Public interface | ISetupSequentialResult<(Of <(<'TResult>)>)> | Language for ReturnSequence
Public interface | IThrows | Defines the Throws verb.
Public interface | IVerifies | Defines the Verifiable verb.


ICallback Interface

ICallback Interface
Members See Also Send Feedback
Defines the Callback verb and overloads.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface ICallback : IHideObjectMembers

See Also

ICallback Members
Moq.Language Namespace


ICallback Members

[image]

Moq
ICallback Members
ICallback Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Callback(Action) | Specifies a callback to invoke when the method is called.
Public method | Callback<(Of <<'(T>)>>)(Action<(Of <<'(T>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2>)>>)(Action<(Of <(<'T1, T2>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3>)>>)(Action<(Of <(<'T1, T2, T3>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <(<'T1, T2, T3, T4>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.

See Also

ICallback Interface
Moq.Language Namespace


ICallback Methods

[image]

Moq
ICallback Methods
ICallback Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Callback(Action) | Specifies a callback to invoke when the method is called.
Public method | Callback<(Of <<'(T>)>>)(Action<(Of <<'(T>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2>)>>)(Action<(Of <(<'T1, T2>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3>)>>)(Action<(Of <(<'T1, T2, T3>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <(<'T1, T2, T3, T4>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.

See Also

ICallback Interface
Moq.Language Namespace


Callback Method

[image]

Moq
ICallback..::..Callback Method
ICallback Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Callback(Action) | Specifies a callback to invoke when the method is called.
Public method | Callback<(Of <<'(T>)>>)(Action<(Of <<'(T>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2>)>>)(Action<(Of <(<'T1, T2>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3>)>>)(Action<(Of <(<'T1, T2, T3>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <(<'T1, T2, T3, T4>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.

See Also

ICallback Interface
ICallback Members
Moq.Language Namespace


Callback Method (Action)

ICallback..::..Callback Method (Action)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback(
    Action action
)

Parameters

action
Type: System..::..Action
The callback method to invoke.

Examples

The following example specifies a callback to set a boolean value that can be used later:
CopyC#
var called = false;
mock.Setup(x => x.Execute())
    .Callback(() => called = true);

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T) Method (Action(T))

ICallback..::..Callback<(Of <(<'T>)>)> Method (Action<(Of <(<'T>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T>(
    Action<T> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T>)>)>
The callback method to invoke.

Type Parameters

T
The argument type of the invoked method.

Examples

Invokes the given callback with the concrete invocation argument value.

Notice how the specific string argument is retrieved by simply declaring it as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(It.IsAny<string>()))
    .Callback((string command) => Console.WriteLine(command));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.
T15
The type of the fifteenth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.
T15
The type of the fifteenth argument of the invoked method.
T16
The type of the sixteenth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15, string arg16) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15 + arg16));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``2(System.Action`2)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2>)>)>

Type Parameters

T1
T2

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2, T3>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``3(System.Action`3)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3>)>)>

Type Parameters

T1
T2
T3

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``4(System.Action`4)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4>)>)>

Type Parameters

T1
T2
T3
T4

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``5(System.Action`5)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5>)>)>

Type Parameters

T1
T2
T3
T4
T5

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``6(System.Action`6)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``7(System.Action`7)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8) Method (Action)

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)> Method (Action)
ICallback Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback.Callback``8(System.Action`8)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9))

ICallback..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)>)
ICallback Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.

Return Value

A reference to ICallbackResult interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9));

See Also

ICallback Interface
Callback Overload
Moq.Language Namespace


ICallback(TMock, TResult) Interface

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Members See Also Send Feedback
Defines the Callback verb and overloads for callbacks on setups that return a value.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface ICallback<TMock, TResult> : IHideObjectMembers
where TMock : class

Type Parameters

TMock
Mocked type.
TResult
Type of the return value of the setup.

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Members
Moq.Language Namespace


ICallback(TMock, TResult) Members

[image]

Moq
ICallback<(Of <(<'TMock, TResult>)>)> Members
ICallback<(Of <(<'TMock, TResult>)>)> Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Callback(Action) | Specifies a callback to invoke when the method is called.
Public method | Callback<(Of <<'(T>)>>)(Action<(Of <<'(T>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2>)>>)(Action<(Of <(<'T1, T2>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3>)>>)(Action<(Of <(<'T1, T2, T3>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <(<'T1, T2, T3, T4>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Moq.Language Namespace


ICallback(TMock, TResult) Methods

[image]

Moq
ICallback<(Of <(<'TMock, TResult>)>)> Methods
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Callback(Action) | Specifies a callback to invoke when the method is called.
Public method | Callback<(Of <<'(T>)>>)(Action<(Of <<'(T>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2>)>>)(Action<(Of <(<'T1, T2>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3>)>>)(Action<(Of <(<'T1, T2, T3>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <(<'T1, T2, T3, T4>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Moq.Language Namespace


Callback Method

[image]

Moq
ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback Method
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Callback(Action) | Specifies a callback to invoke when the method is called.
Public method | Callback<(Of <<'(T>)>>)(Action<(Of <<'(T>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.
Public method | Callback<(Of <<'(T1, T2>)>>)(Action<(Of <(<'T1, T2>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3>)>>)(Action<(Of <(<'T1, T2, T3>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <(<'T1, T2, T3, T4>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>) |
Public method | Callback<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)) | Specifies a callback to invoke when the method is called that receives the original arguments.

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
ICallback<(Of <(<'TMock, TResult>)>)> Members
Moq.Language Namespace


Callback Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback(
    Action action
)

Parameters

action
Type: System..::..Action
The callback method to invoke.

Examples

The following example specifies a callback to set a boolean value that can be used later:
CopyC#
var called = false;
mock.Setup(x => x.Execute())
    .Callback(() => called = true)
    .Returns(true);
 Note that in the case of value-returning methods, after the Callback call you can still specify the return value.

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T) Method (Action(T))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T>)>)> Method (Action<(Of <(<'T>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T>(
    Action<T> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T>)>)>
Callback method to invoke.

Type Parameters

T
The type of the argument of the invoked method.

Examples

Invokes the given callback with the concrete invocation argument value.

Notice how the specific string argument is retrieved by simply declaring it as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(It.IsAny<string>()))
    .Callback(command => Console.WriteLine(command))
    .Returns(true);

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.
T15
The type of the fifteenth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.
T15
The type of the fifteenth argument of the invoked method.
T16
The type of the sixteenth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15 + arg16));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``2(System.Action`2)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2>)>)>

Type Parameters

T1
T2

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``3(System.Action`3)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3>)>)>

Type Parameters

T1
T2
T3

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``4(System.Action`4)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4>)>)>

Type Parameters

T1
T2
T3
T4

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``5(System.Action`5)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5>)>)>

Type Parameters

T1
T2
T3
T4
T5

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``6(System.Action`6)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``7(System.Action`7)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8) Method (Action)

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)> Method (Action)
ICallback<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ICallback`2.Callback``8(System.Action`8)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8>(
    Action action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9))

ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)>)
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
    Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> action
)

Parameters

action
Type: System..::..Action <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)>
The callback method to invoke.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9));

See Also

ICallback<(Of <(<'TMock, TResult>)>)> Interface
Callback Overload
Moq.Language Namespace


ICallbackGetter(TMock, TProperty) Interface

ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface
Members See Also Send Feedback
Defines the Callback verb for property getter setups.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface ICallbackGetter<TMock, TProperty> : IHideObjectMembers
where TMock : class

Type Parameters

TMock
Mocked type.
TProperty
Type of the property.

See Also

ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Members
Moq.Language Namespace
MockSetupGet``1(Expression<(Of <<'(Func<(Of <<'(UTP, UMP>)>>)>)>>))


ICallbackGetter(TMock, TProperty) Members

[image]

Moq
ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Members
ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface Methods See Also Send Feedback

The ICallbackGetter<(Of <(<'TMock, TProperty>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Callback | Specifies a callback to invoke when the property is retrieved.

See Also

ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface
Moq.Language Namespace


ICallbackGetter(TMock, TProperty) Methods

[image]

Moq
ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Methods
ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface See Also Send Feedback

The ICallbackGetter<(Of <(<'TMock, TProperty>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Callback | Specifies a callback to invoke when the property is retrieved.

See Also

ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface
Moq.Language Namespace


Callback Method

ICallbackGetter<(Of <(<'TMock, TProperty>)>)>..::..Callback Method
ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the property is retrieved.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsThrowsGetter<TMock, TProperty> Callback(
    Action action
)

Parameters

action
Type: System..::..Action
Callback method to invoke.

Examples

Invokes the given callback with the property value being set.
CopyC#
mock.SetupGet(x => x.Suspended)
    .Callback(() => called = true)
    .Returns(true);

See Also

ICallbackGetter<(Of <(<'TMock, TProperty>)>)> Interface
Moq.Language Namespace


ICallbackSetter(TProperty) Interface

ICallbackSetter<(Of <(<'TProperty>)>)> Interface
Members See Also Send Feedback
Defines the Callback verb for property setter setups.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface ICallbackSetter<TProperty> : IHideObjectMembers

Type Parameters

TProperty
Type of the property.

See Also

ICallbackSetter<(Of <(<'TProperty>)>)> Members
Moq.Language Namespace


ICallbackSetter(TProperty) Members

[image]

Moq
ICallbackSetter<(Of <(<'TProperty>)>)> Members
ICallbackSetter<(Of <(<'TProperty>)>)> Interface Methods See Also Send Feedback

The ICallbackSetter<(Of <(<'TProperty>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Callback | Specifies a callback to invoke when the property is set that receives the property value being set.

See Also

ICallbackSetter<(Of <(<'TProperty>)>)> Interface
Moq.Language Namespace


ICallbackSetter(TProperty) Methods

[image]

Moq
ICallbackSetter<(Of <(<'TProperty>)>)> Methods
ICallbackSetter<(Of <(<'TProperty>)>)> Interface See Also Send Feedback

The ICallbackSetter<(Of <(<'TProperty>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Callback | Specifies a callback to invoke when the property is set that receives the property value being set.

See Also

ICallbackSetter<(Of <(<'TProperty>)>)> Interface
Moq.Language Namespace


Callback Method

ICallbackSetter<(Of <(<'TProperty>)>)>..::..Callback Method
ICallbackSetter<(Of <(<'TProperty>)>)> Interface Example See Also Send Feedback
Specifies a callback to invoke when the property is set that receives the property value being set.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback(
    Action<TProperty> action
)

Parameters

action
Type: System..::..Action <(Of <(<' TProperty >)>)>
Callback method to invoke.

Examples

Invokes the given callback with the property value being set.
CopyC#
mock.SetupSet(x => x.Suspended)
    .Callback((bool state) => Console.WriteLine(state));

See Also

ICallbackSetter<(Of <(<'TProperty>)>)> Interface
Moq.Language Namespace


IRaise(T) Interface

IRaise<(Of <(<'T>)>)> Interface
Members See Also Send Feedback
Defines the Raises verb.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface IRaise<T> : IHideObjectMembers

Type Parameters

T

See Also

IRaise<(Of <(<'T>)>)> Members
Moq.Language Namespace


IRaise(T) Members

[image]

Moq
IRaise<(Of <(<'T>)>)> Members
IRaise<(Of <(<'T>)>)> Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Raises(Action<(Of <<'(T>)>>), EventArgs) | Specifies the event that will be raised when the setup is met.
Public method | Raises(Action<(Of <<'(T>)>>), Func<(Of <(<'TResult>)>)>) |
Public method | Raises(Action<(Of <<'(T>)>>), array<Object>[]()[][]) | Specifies the custom event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.

See Also

IRaise<(Of <(<'T>)>)> Interface
Moq.Language Namespace


IRaise(T) Methods

[image]

Moq
IRaise<(Of <(<'T>)>)> Methods
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Raises(Action<(Of <<'(T>)>>), EventArgs) | Specifies the event that will be raised when the setup is met.
Public method | Raises(Action<(Of <<'(T>)>>), Func<(Of <(<'TResult>)>)>) |
Public method | Raises(Action<(Of <<'(T>)>>), array<Object>[]()[][]) | Specifies the custom event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.

See Also

IRaise<(Of <(<'T>)>)> Interface
Moq.Language Namespace


Raises Method

[image]

Moq
IRaise<(Of <(<'T>)>)>..::..Raises Method
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Raises(Action<(Of <<'(T>)>>), EventArgs) | Specifies the event that will be raised when the setup is met.
Public method | Raises(Action<(Of <<'(T>)>>), Func<(Of <(<'TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Action<(Of <<'(T>)>>), Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs>)>>)) | Specifies the event that will be raised when the setup is matched.
Public method | Raises<(Of <<'(T1>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>) |
Public method | Raises<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Action<(Of <<'(T>)>>), Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>) |
Public method | Raises(Action<(Of <<'(T>)>>), array<Object>[]()[][]) | Specifies the custom event that will be raised when the setup is matched.

See Also

IRaise<(Of <(<'T>)>)> Interface
IRaise<(Of <(<'T>)>)> Members
Moq.Language Namespace


Raises Method (Action(T), EventArgs)

IRaise<(Of <(<'T>)>)>..::..Raises Method (Action<(Of <(<'T>)>)>, EventArgs)
IRaise<(Of <(<'T>)>)> Interface Example See Also Send Feedback
Specifies the event that will be raised when the setup is met.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises(
    Action<T> eventExpression,
    EventArgs args
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
An expression that represents an event attach or detach action.
args
Type: System..::..EventArgs
The event arguments to pass for the raised event.

Examples

The following example shows how to raise an event when the setup is met:
CopyC#
var mock = new Mock<IContainer>();

mock.Setup(add => add.Add(It.IsAny<string>(), It.IsAny<object>()))
    .Raises(add => add.Added += null, EventArgs.Empty);

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.Func`1)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'TResult>)>)>

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.
T11
The type of the eleventh argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.
T11
The type of the eleventh argument received by the expected invocation.
T12
The type of the twelfth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.
T11
The type of the eleventh argument received by the expected invocation.
T12
The type of the twelfth argument received by the expected invocation.
T13
The type of the thirteenth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.
T11
The type of the eleventh argument received by the expected invocation.
T12
The type of the twelfth argument received by the expected invocation.
T13
The type of the thirteenth argument received by the expected invocation.
T14
The type of the fourteenth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.
T11
The type of the eleventh argument received by the expected invocation.
T12
The type of the twelfth argument received by the expected invocation.
T13
The type of the thirteenth argument received by the expected invocation.
T14
The type of the fourteenth argument received by the expected invocation.
T15
The type of the fifteenth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) Method (Action(T), Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs))

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)> Method (Action<(Of <(<'T>)>)>, Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs>)>)>)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
    Action<T> eventExpression,
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs> func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
The expression that represents an event attach or detach action.
func
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, EventArgs >)>)>
The function that will build the EventArgs to pass when raising the event.

Type Parameters

T1
The type of the first argument received by the expected invocation.
T2
The type of the second argument received by the expected invocation.
T3
The type of the third argument received by the expected invocation.
T4
The type of the fourth argument received by the expected invocation.
T5
The type of the fifth argument received by the expected invocation.
T6
The type of the sixth argument received by the expected invocation.
T7
The type of the seventh argument received by the expected invocation.
T8
The type of the eighth argument received by the expected invocation.
T9
The type of the nineth argument received by the expected invocation.
T10
The type of the tenth argument received by the expected invocation.
T11
The type of the eleventh argument received by the expected invocation.
T12
The type of the twelfth argument received by the expected invocation.
T13
The type of the thirteenth argument received by the expected invocation.
T14
The type of the fourteenth argument received by the expected invocation.
T15
The type of the fifteenth argument received by the expected invocation.
T16
The type of the sixteenth argument received by the expected invocation.

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace
IRaise<(Of <(<'T>)>)>..::..Raises(Action<(Of <<'(T>)>>), EventArgs)


Raises(T1) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``1(System.Action{`0},System.Func`2)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T, TResult>)>)>

Type Parameters

T1

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``2(System.Action{`0},System.Func`3)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, TResult>)>)>

Type Parameters

T1
T2

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``3(System.Action{`0},System.Func`4)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, T3, TResult>)>)>

Type Parameters

T1
T2
T3

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3, T4) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``4(System.Action{`0},System.Func`5)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>

Type Parameters

T1
T2
T3
T4

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3, T4, T5) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``5(System.Action{`0},System.Func`6)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3, T4, T5, T6) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``6(System.Action{`0},System.Func`7)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3, T4, T5, T6, T7) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``7(System.Action{`0},System.Func`8)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises(T1, T2, T3, T4, T5, T6, T7, T8) Method (Action(T), Func)

IRaise<(Of <(<'T>)>)>..::..Raises<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)> Method (Action<(Of <(<'T>)>)>, Func)
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IRaise`1.Raises``8(System.Action{`0},System.Func`9)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises<T1, T2, T3, T4, T5, T6, T7, T8>(
    Action<T> eventExpression,
    Func func
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
func
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


Raises Method (Action(T), Object[])

IRaise<(Of <(<'T>)>)>..::..Raises Method (Action<(Of <(<'T>)>)>, array<Object>[]()[][])
IRaise<(Of <(<'T>)>)> Interface See Also Send Feedback
Specifies the custom event that will be raised when the setup is matched.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IVerifies Raises(
    Action<T> eventExpression,
    params Object[] args
)

Parameters

eventExpression
Type: System..::..Action <(Of <(<' T >)>)>
An expression that represents an event attach or detach action.
args
Type: array< System..::..Object >[]()[][]
The arguments to pass to the custom delegate (non EventHandler-compatible).

See Also

IRaise<(Of <(<'T>)>)> Interface
Raises Overload
Moq.Language Namespace


IReturns(TMock, TResult) Interface

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Members See Also Send Feedback
Defines the Returns verb.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface IReturns<TMock, TResult> : IHideObjectMembers
where TMock : class

Type Parameters

TMock
Mocked type.
TResult
Type of the return value from the expression.

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Members
Moq.Language Namespace


IReturns(TMock, TResult) Members

[image]

Moq
IReturns<(Of <(<'TMock, TResult>)>)> Members
IReturns<(Of <(<'TMock, TResult>)>)> Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Returns(Func<(Of <(<'TResult>)>)>) |
Public method | Returns(TResult) | Specifies the value to return.
Public method | Returns<(Of <<'(T>)>>)(Func<(Of <(<'T, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2>)>>)(Func<(Of <(<'T1, T2, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3>)>>)(Func<(Of <(<'T1, T2, T3, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4>)>>)(Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Moq.Language Namespace


IReturns(TMock, TResult) Methods

[image]

Moq
IReturns<(Of <(<'TMock, TResult>)>)> Methods
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Returns(Func<(Of <(<'TResult>)>)>) |
Public method | Returns(TResult) | Specifies the value to return.
Public method | Returns<(Of <<'(T>)>>)(Func<(Of <(<'T, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2>)>>)(Func<(Of <(<'T1, T2, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3>)>>)(Func<(Of <(<'T1, T2, T3, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4>)>>)(Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Moq.Language Namespace


Returns Method

[image]

Moq
IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns Method
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Returns(Func<(Of <(<'TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>>)(Func<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>)>>)) | Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.
Public method | Returns<(Of <<'(T>)>>)(Func<(Of <(<'T, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2>)>>)(Func<(Of <(<'T1, T2, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3>)>>)(Func<(Of <(<'T1, T2, T3, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4>)>>)(Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>) |
Public method | Returns<(Of <<'(T1, T2, T3, T4, T5, T6, T7, T8>)>>)(Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>) |
Public method | Returns(TResult) | Specifies the value to return.

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
IReturns<(Of <(<'TMock, TResult>)>)> Members
Moq.Language Namespace


Returns Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns(System.Func`1)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'TResult>)>)>

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.
T15
The type of the fifteenth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) Method (Func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult))

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>)>)>)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies a function that will calculate the value to return from the method, retrieving the arguments for the invocation.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
    Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> valueFunction
)

Parameters

valueFunction
Type: System..::..Func <(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult >)>)>
The function that will calculate the return value.

Type Parameters

T1
The type of the first argument of the invoked method.
T2
The type of the second argument of the invoked method.
T3
The type of the third argument of the invoked method.
T4
The type of the fourth argument of the invoked method.
T5
The type of the fifth argument of the invoked method.
T6
The type of the sixth argument of the invoked method.
T7
The type of the seventh argument of the invoked method.
T8
The type of the eighth argument of the invoked method.
T9
The type of the nineth argument of the invoked method.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.
T12
The type of the twelfth argument of the invoked method.
T13
The type of the thirteenth argument of the invoked method.
T14
The type of the fourteenth argument of the invoked method.
T15
The type of the fifteenth argument of the invoked method.
T16
The type of the sixteenth argument of the invoked method.

Examples

The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

CopyC#
mock.Setup(x => x.Execute(
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>(),
                     It.IsAny<int>()))
    .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12, string arg13, string arg14, string arg15, string arg16) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12 + arg13 + arg14 + arg15 + arg16);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``1(System.Func`2)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T, TResult>)>)>

Type Parameters

T

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``2(System.Func`3)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, TResult>)>)>

Type Parameters

T1
T2

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``3(System.Func`4)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, T3, TResult>)>)>

Type Parameters

T1
T2
T3

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``4(System.Func`5)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, TResult>)>)>

Type Parameters

T1
T2
T3
T4

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``5(System.Func`6)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``6(System.Func`7)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``7(System.Func`8)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns(T1, T2, T3, T4, T5, T6, T7, T8) Method (Func)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8>)>)> Method (Func)
IReturns<(Of <(<'TMock, TResult>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturns`2.Returns``8(System.Func`9)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8>(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, TResult>)>)>

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns Method (TResult)

IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns Method (TResult)
IReturns<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback
Specifies the value to return.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns(
    TResult value
)

Parameters

value
Type: TResult
The value to return, or nullNothingnullptra null reference (Nothing in Visual Basic).

Examples

Return a true value from the method call:
CopyC#
mock.Setup(x => x.Execute("ping"))
    .Returns(true);

See Also

IReturns<(Of <(<'TMock, TResult>)>)> Interface
Returns Overload
Moq.Language Namespace


IReturnsGetter(TMock, TProperty) Interface

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface
Members See Also Send Feedback
Defines the Returns verb for property get setups.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface IReturnsGetter<TMock, TProperty> : IHideObjectMembers
where TMock : class

Type Parameters

TMock
Mocked type.
TProperty
Type of the property.

See Also

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Members
Moq.Language Namespace


IReturnsGetter(TMock, TProperty) Members

[image]

Moq
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Members
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Returns(Func<(Of <(<'TResult>)>)>) |
Public method | Returns(TProperty) | Specifies the value to return.

See Also

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface
Moq.Language Namespace


IReturnsGetter(TMock, TProperty) Methods

[image]

Moq
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Methods
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Returns(Func<(Of <(<'TResult>)>)>) |
Public method | Returns(TProperty) | Specifies the value to return.

See Also

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface
Moq.Language Namespace


Returns Method

[image]

Moq
IReturnsGetter<(Of <(<'TMock, TProperty>)>)>..::..Returns Method
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Returns(Func<(Of <(<'TResult>)>)>) |
Public method | Returns(TProperty) | Specifies the value to return.

See Also

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Members
Moq.Language Namespace


Returns Method (Func)

IReturnsGetter<(Of <(<'TMock, TProperty>)>)>..::..Returns Method (Func)
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.IReturnsGetter`2.Returns(System.Func`1)"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns(
    Func valueFunction
)

Parameters

valueFunction
Type: System..::..Func<(Of <(<'TResult>)>)>

See Also

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface
Returns Overload
Moq.Language Namespace


Returns Method (TProperty)

IReturnsGetter<(Of <(<'TMock, TProperty>)>)>..::..Returns Method (TProperty)
IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface Example See Also Send Feedback
Specifies the value to return.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IReturnsResult<TMock> Returns(
    TProperty value
)

Parameters

value
Type: TProperty
The value to return, or nullNothingnullptra null reference (Nothing in Visual Basic).

Examples

Return a true value from the property getter call:
CopyC#
mock.SetupGet(x => x.Suspended)
    .Returns(true);

See Also

IReturnsGetter<(Of <(<'TMock, TProperty>)>)> Interface
Returns Overload
Moq.Language Namespace


ISetupConditionResult(T) Interface

ISetupConditionResult<(Of <(<'T>)>)> Interface
Members See Also Send Feedback
Implements the fluent API.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface ISetupConditionResult<T>
where T : class

Type Parameters

T

See Also

ISetupConditionResult<(Of <(<'T>)>)> Members
Moq.Language Namespace


ISetupConditionResult(T) Members

[image]

Moq
ISetupConditionResult<(Of <(<'T>)>)> Members
ISetupConditionResult<(Of <(<'T>)>)> Interface Methods See Also Send Feedback

The ISetupConditionResult<(Of <(<'T>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Setup(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | The expectation will be considered only in the former condition.
Public method | Setup<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupGet<(Of <<'(TProperty>)>>) |
Public method | SetupSet(Action<(Of <<'(T>)>>)) | Setups the set.
Public method | SetupSet<(Of <<'(TProperty>)>>)(Action<(Of <<'(T>)>>)) | Setups the set.

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
Moq.Language Namespace


ISetupConditionResult(T) Methods

[image]

Moq
ISetupConditionResult<(Of <(<'T>)>)> Methods
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback

The ISetupConditionResult<(Of <(<'T>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Setup(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | The expectation will be considered only in the former condition.
Public method | Setup<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |
Public method | SetupGet<(Of <<'(TProperty>)>>) |
Public method | SetupSet(Action<(Of <<'(T>)>>)) | Setups the set.
Public method | SetupSet<(Of <<'(TProperty>)>>)(Action<(Of <<'(T>)>>)) | Setups the set.

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
Moq.Language Namespace


Setup Method

[image]

Moq
ISetupConditionResult<(Of <(<'T>)>)>..::..Setup Method
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Setup(Expression<(Of <<'(Action<(Of <<'(T>)>>)>)>>)) | The expectation will be considered only in the former condition.
Public method | Setup<(Of <<'(TResult>)>>)(Expression<(Of <<'(Func<(Of <(<'T, TResult>)>)>>)>>)) |

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
ISetupConditionResult<(Of <(<'T>)>)> Members
Moq.Language Namespace


Setup Method (Expression(Action(T)))

ISetupConditionResult<(Of <(<'T>)>)>..::..Setup Method (Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>)
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback
The expectation will be considered only in the former condition.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetup<T> Setup(
    Expression<Action<T>> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Action <(Of <(<' T >)>)>>)>)>

Return Value

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
Setup Overload
Moq.Language Namespace


Setup(TResult) Method (Expression(Func))

ISetupConditionResult<(Of <(<'T>)>)>..::..Setup<(Of <(<'TResult>)>)> Method (Expression<(Of <(<'Func>)>)>)
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ISetupConditionResult`1.Setup``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetup<T, TResult> Setup<TResult>(
    Expression<Func> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TResult

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
Setup Overload
Moq.Language Namespace


SetupGet(TProperty) Method

ISetupConditionResult<(Of <(<'T>)>)>..::..SetupGet<(Of <(<'TProperty>)>)> Method
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Language.ISetupConditionResult`1.SetupGet``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetupGetter<T, TProperty> SetupGet<TProperty>(
    Expression<Func> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TProperty

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
Moq.Language Namespace


SetupSet Method

[image]

Moq
ISetupConditionResult<(Of <(<'T>)>)>..::..SetupSet Method
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | SetupSet(Action<(Of <<'(T>)>>)) | Setups the set.
Public method | SetupSet<(Of <<'(TProperty>)>>)(Action<(Of <<'(T>)>>)) | Setups the set.

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
ISetupConditionResult<(Of <(<'T>)>)> Members
Moq.Language Namespace


SetupSet Method (Action(T))

ISetupConditionResult<(Of <(<'T>)>)>..::..SetupSet Method (Action<(Of <(<'T>)>)>)
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback
Setups the set.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetup<T> SetupSet(
    Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
The setter expression.

Return Value

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
SetupSet Overload
Moq.Language Namespace


SetupSet(TProperty) Method (Action(T))

ISetupConditionResult<(Of <(<'T>)>)>..::..SetupSet<(Of <(<'TProperty>)>)> Method (Action<(Of <(<'T>)>)>)
ISetupConditionResult<(Of <(<'T>)>)> Interface See Also Send Feedback
Setups the set.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetupSetter<T, TProperty> SetupSet<TProperty>(
    Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action <(Of <(<' T >)>)>
The setter expression.

Type Parameters

TProperty
The type of the property.

Return Value

See Also

ISetupConditionResult<(Of <(<'T>)>)> Interface
SetupSet Overload
Moq.Language Namespace


ISetupSequentialResult(TResult) Interface

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
Members See Also Send Feedback
Language for ReturnSequence

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface ISetupSequentialResult<TResult>

Type Parameters

TResult

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Members
Moq.Language Namespace


ISetupSequentialResult(TResult) Members

[image]

Moq
ISetupSequentialResult<(Of <(<'TResult>)>)> Members
ISetupSequentialResult<(Of <(<'TResult>)>)> Interface Methods See Also Send Feedback

The ISetupSequentialResult<(Of <(<'TResult>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Returns | Returns value
Public method | Throws(Exception) | Throws an exception
Public method | Throws<(Of <<'(TException>)>>)()()()() | Throws an exception

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
Moq.Language Namespace


ISetupSequentialResult(TResult) Methods

[image]

Moq
ISetupSequentialResult<(Of <(<'TResult>)>)> Methods
ISetupSequentialResult<(Of <(<'TResult>)>)> Interface See Also Send Feedback

The ISetupSequentialResult<(Of <(<'TResult>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Returns | Returns value
Public method | Throws(Exception) | Throws an exception
Public method | Throws<(Of <<'(TException>)>>)()()()() | Throws an exception

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
Moq.Language Namespace


Returns Method

ISetupSequentialResult<(Of <(<'TResult>)>)>..::..Returns Method
ISetupSequentialResult<(Of <(<'TResult>)>)> Interface See Also Send Feedback
Returns value

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetupSequentialResult<TResult> Returns(
    TResult value
)

Parameters

value
Type: TResult

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
Moq.Language Namespace


Throws Method

[image]

Moq
ISetupSequentialResult<(Of <(<'TResult>)>)>..::..Throws Method
ISetupSequentialResult<(Of <(<'TResult>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Throws<(Of <<'(TException>)>>)()()()() | Throws an exception
Public method | Throws(Exception) | Throws an exception

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
ISetupSequentialResult<(Of <(<'TResult>)>)> Members
Moq.Language Namespace


Throws(TException) Method

ISetupSequentialResult<(Of <(<'TResult>)>)>..::..Throws<(Of <(<'TException>)>)> Method
ISetupSequentialResult<(Of <(<'TResult>)>)> Interface See Also Send Feedback
Throws an exception

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void Throws<TException>()
where TException : new(), Exception

Type Parameters

TException

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
Throws Overload
Moq.Language Namespace


Throws Method (Exception)

ISetupSequentialResult<(Of <(<'TResult>)>)>..::..Throws Method (Exception)
ISetupSequentialResult<(Of <(<'TResult>)>)> Interface See Also Send Feedback
Throws an exception

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void Throws(
    Exception exception
)

Parameters

exception
Type: System..::..Exception

See Also

ISetupSequentialResult<(Of <(<'TResult>)>)> Interface
Throws Overload
Moq.Language Namespace


IThrows Interface

IThrows Interface
Members See Also Send Feedback
Defines the Throws verb.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface IThrows : IHideObjectMembers

See Also

IThrows Members
Moq.Language Namespace


IThrows Members

[image]

Moq
IThrows Members
IThrows Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Throws(Exception) | Specifies the exception to throw when the method is invoked.
Public method | Throws<(Of <<'(TException>)>>)()()()() | Specifies the type of exception to throw when the method is invoked.

See Also

IThrows Interface
Moq.Language Namespace


IThrows Methods

[image]

Moq
IThrows Methods
IThrows Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Throws(Exception) | Specifies the exception to throw when the method is invoked.
Public method | Throws<(Of <<'(TException>)>>)()()()() | Specifies the type of exception to throw when the method is invoked.

See Also

IThrows Interface
Moq.Language Namespace


Throws Method

[image]

Moq
IThrows..::..Throws Method
IThrows Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Throws<(Of <<'(TException>)>>)()()()() | Specifies the type of exception to throw when the method is invoked.
Public method | Throws(Exception) | Specifies the exception to throw when the method is invoked.

See Also

IThrows Interface
IThrows Members
Moq.Language Namespace


Throws(TException) Method

IThrows..::..Throws<(Of <(<'TException>)>)> Method
IThrows Interface Example See Also Send Feedback
Specifies the type of exception to throw when the method is invoked.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IThrowsResult Throws<TException>()
where TException : new(), Exception

Type Parameters

TException
Type of exception to instantiate and throw when the setup is matched.

Examples

This example shows how to throw an exception when the method is invoked with an empty string argument:
CopyC#
mock.Setup(x => x.Execute(""))
    .Throws<ArgumentException>();

See Also

IThrows Interface
Throws Overload
Moq.Language Namespace


Throws Method (Exception)

IThrows..::..Throws Method (Exception)
IThrows Interface Example See Also Send Feedback
Specifies the exception to throw when the method is invoked.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
IThrowsResult Throws(
    Exception exception
)

Parameters

exception
Type: System..::..Exception
Exception instance to throw.

Examples

This example shows how to throw an exception when the method is invoked with an empty string argument:
CopyC#
mock.Setup(x => x.Execute(""))
    .Throws(new ArgumentException());

See Also

IThrows Interface
Throws Overload
Moq.Language Namespace


IVerifies Interface

IVerifies Interface
Members See Also Send Feedback
Defines the Verifiable verb.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface IVerifies : IHideObjectMembers

See Also

IVerifies Members
Moq.Language Namespace


IVerifies Members

[image]

Moq
IVerifies Members
IVerifies Interface Methods See Also Send Feedback

Methods

 | Name | Description
Public method | Verifiable()()()() | Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met.
Public method | Verifiable(String) | Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met, and specifies a message for failures.

See Also

IVerifies Interface
Moq.Language Namespace


IVerifies Methods

[image]

Moq
IVerifies Methods
IVerifies Interface See Also Send Feedback

Methods

 | Name | Description
Public method | Verifiable()()()() | Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met.
Public method | Verifiable(String) | Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met, and specifies a message for failures.

See Also

IVerifies Interface
Moq.Language Namespace


Verifiable Method

[image]

Moq
IVerifies..::..Verifiable Method
IVerifies Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Verifiable()()()() | Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met.
Public method | Verifiable(String) | Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met, and specifies a message for failures.

See Also

IVerifies Interface
IVerifies Members
Moq.Language Namespace


Verifiable Method

IVerifies..::..Verifiable Method
IVerifies Interface Example See Also Send Feedback
Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void Verifiable()

Examples

The following example marks the expectation as verifiable:
CopyC#
mock.Expect(x => x.Execute("ping"))
    .Returns(true)
    .Verifiable();

See Also

IVerifies Interface
Verifiable Overload
Moq.Language Namespace


Verifiable Method (String)

IVerifies..::..Verifiable Method (String)
IVerifies Interface Example See Also Send Feedback
Marks the expectation as verifiable, meaning that a call to Verify()()()() will check if this particular expectation was met, and specifies a message for failures.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void Verifiable(
    string failMessage
)

Parameters

failMessage
Type: System..::..String

Examples

The following example marks the expectation as verifiable:
CopyC#
mock.Expect(x => x.Execute("ping"))
    .Returns(true)
    .Verifiable("Ping should be executed always!");

See Also

IVerifies Interface
Verifiable Overload
Moq.Language Namespace


Moq.Protected Namespace

Moq.Protected Namespace
Send Feedback
Importing this namespace will enable the Protected() method on mocks, enabling expectations on protected members by specifying the member name as a string.

Classes

 | Class | Description
Public class | ItExpr | Allows the specification of a matching condition for an argument in a protected member setup, rather than a specific argument value. "ItExpr" refers to the argument being matched.
Public class | ProtectedExtension | Enables the Protected() method on Mock<(Of <(<'T>)>)>, allowing setups to be set for protected members by using their name as a string, rather than strong-typing them which is not possible due to their visibility.

Interfaces

 | Interface | Description
Public interface | IProtectedMock<(Of <(<'TMock>)>)> | Allows setups to be specified for protected members by using their name as a string, rather than strong-typing them which is not possible due to their visibility.


IProtectedMock(TMock) Interface

IProtectedMock<(Of <(<'TMock>)>)> Interface
Members See Also Send Feedback
Allows setups to be specified for protected members by using their name as a string, rather than strong-typing them which is not possible due to their visibility.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public interface IProtectedMock<TMock> : IHideObjectMembers
where TMock : class

Type Parameters

TMock

See Also

IProtectedMock<(Of <(<'TMock>)>)> Members
Moq.Protected Namespace


IProtectedMock(TMock) Members

[image]

Moq
IProtectedMock<(Of <(<'TMock>)>)> Members
IProtectedMock<(Of <(<'TMock>)>)> Interface Methods See Also Send Feedback

The IProtectedMock<(Of <(<'TMock>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Setup(String, array<Object>[]()[][]) | Specifies a setup for a void method invocation with the given voidMethodName, optionally specifying arguments for the method call.
Public method | Setup<(Of <<'(TResult>)>>)(String, array<Object>[]()[][]) | Specifies a setup for an invocation on a property or a non void method with the given methodOrPropertyName, optionally specifying arguments for the method call.
Public method | SetupGet<(Of <<'(TProperty>)>>) | Specifies a setup for an invocation on a property getter with the given propertyName.
Public method | SetupSet<(Of <<'(TProperty>)>>) | Specifies a setup for an invocation on a property setter with the given propertyName.
Public method | Verify(String, Times, array<Object>[]()[][]) | Specifies a verify for a void method with the given methodName, optionally specifying arguments for the method call. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(String, Times, array<Object>[]()[][]) | Specifies a verify for an invocation on a property or a non void method with the given methodName, optionally specifying arguments for the method call.
Public method | VerifyGet<(Of <<'(TProperty>)>>) | Specifies a verify for an invocation on a property getter with the given propertyName. The invocation was not call the times specified by times.
Public method | VerifySet<(Of <<'(TProperty>)>>) | Specifies a setup for an invocation on a property setter with the given propertyName.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Moq.Protected Namespace


IProtectedMock(TMock) Methods

[image]

Moq
IProtectedMock<(Of <(<'TMock>)>)> Methods
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback

The IProtectedMock<(Of <(<'TMock>)>)> type exposes the following members.

Methods

 | Name | Description
Public method | Setup(String, array<Object>[]()[][]) | Specifies a setup for a void method invocation with the given voidMethodName, optionally specifying arguments for the method call.
Public method | Setup<(Of <<'(TResult>)>>)(String, array<Object>[]()[][]) | Specifies a setup for an invocation on a property or a non void method with the given methodOrPropertyName, optionally specifying arguments for the method call.
Public method | SetupGet<(Of <<'(TProperty>)>>) | Specifies a setup for an invocation on a property getter with the given propertyName.
Public method | SetupSet<(Of <<'(TProperty>)>>) | Specifies a setup for an invocation on a property setter with the given propertyName.
Public method | Verify(String, Times, array<Object>[]()[][]) | Specifies a verify for a void method with the given methodName, optionally specifying arguments for the method call. Use in conjuntion with the default Loose.
Public method | Verify<(Of <<'(TResult>)>>)(String, Times, array<Object>[]()[][]) | Specifies a verify for an invocation on a property or a non void method with the given methodName, optionally specifying arguments for the method call.
Public method | VerifyGet<(Of <<'(TProperty>)>>) | Specifies a verify for an invocation on a property getter with the given propertyName. The invocation was not call the times specified by times.
Public method | VerifySet<(Of <<'(TProperty>)>>) | Specifies a setup for an invocation on a property setter with the given propertyName.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Moq.Protected Namespace


Setup Method

[image]

Moq
IProtectedMock<(Of <(<'TMock>)>)>..::..Setup Method
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Setup<(Of <<'(TResult>)>>)(String, array<Object>[]()[][]) | Specifies a setup for an invocation on a property or a non void method with the given methodOrPropertyName, optionally specifying arguments for the method call.
Public method | Setup(String, array<Object>[]()[][]) | Specifies a setup for a void method invocation with the given voidMethodName, optionally specifying arguments for the method call.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
IProtectedMock<(Of <(<'TMock>)>)> Members
Moq.Protected Namespace


Setup(TResult) Method (String, Object[])

IProtectedMock<(Of <(<'TMock>)>)>..::..Setup<(Of <(<'TResult>)>)> Method (String, array<Object>[]()[][])
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a setup for an invocation on a property or a non void method with the given methodOrPropertyName, optionally specifying arguments for the method call.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetup<TMock, TResult> Setup<TResult>(
    string methodOrPropertyName,
    params Object[] args
)

Parameters

methodOrPropertyName
Type: System..::..String
The name of the method or property to be invoked.
args
Type: array< System..::..Object >[]()[][]
The optional arguments for the invocation. If argument matchers are used, remember to use ItExpr rather than It.

Type Parameters

TResult
The return type of the method or property.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Setup Overload
Moq.Protected Namespace


Setup Method (String, Object[])

IProtectedMock<(Of <(<'TMock>)>)>..::..Setup Method (String, array<Object>[]()[][])
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a setup for a void method invocation with the given voidMethodName, optionally specifying arguments for the method call.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetup<TMock> Setup(
    string voidMethodName,
    params Object[] args
)

Parameters

voidMethodName
Type: System..::..String
The name of the void method to be invoked.
args
Type: array< System..::..Object >[]()[][]
The optional arguments for the invocation. If argument matchers are used, remember to use ItExpr rather than It.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Setup Overload
Moq.Protected Namespace


SetupGet(TProperty) Method

IProtectedMock<(Of <(<'TMock>)>)>..::..SetupGet<(Of <(<'TProperty>)>)> Method
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a setup for an invocation on a property getter with the given propertyName.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetupGetter<TMock, TProperty> SetupGet<TProperty>(
    string propertyName
)

Parameters

propertyName
Type: System..::..String
The name of the property.

Type Parameters

TProperty
The type of the property.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Moq.Protected Namespace


SetupSet(TProperty) Method

IProtectedMock<(Of <(<'TMock>)>)>..::..SetupSet<(Of <(<'TProperty>)>)> Method
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a setup for an invocation on a property setter with the given propertyName.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ISetupSetter<TMock, TProperty> SetupSet<TProperty>(
    string propertyName,
    Object value
)

Parameters

propertyName
Type: System..::..String
The name of the property.
value
Type: System..::..Object
The property value. If argument matchers are used, remember to use ItExpr rather than It.

Type Parameters

TProperty
The type of the property.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Moq.Protected Namespace


Verify Method

[image]

Moq
IProtectedMock<(Of <(<'TMock>)>)>..::..Verify Method
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback

Overload List

 | Name | Description
Public method | Verify<(Of <<'(TResult>)>>)(String, Times, array<Object>[]()[][]) | Specifies a verify for an invocation on a property or a non void method with the given methodName, optionally specifying arguments for the method call.
Public method | Verify(String, Times, array<Object>[]()[][]) | Specifies a verify for a void method with the given methodName, optionally specifying arguments for the method call. Use in conjuntion with the default Loose.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
IProtectedMock<(Of <(<'TMock>)>)> Members
Moq.Protected Namespace


Verify(TResult) Method (String, Times, Object[])

IProtectedMock<(Of <(<'TMock>)>)>..::..Verify<(Of <(<'TResult>)>)> Method (String, Times, array<Object>[]()[][])
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a verify for an invocation on a property or a non void method with the given methodName, optionally specifying arguments for the method call.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void Verify<TResult>(
    string methodName,
    Times times,
    params Object[] args
)

Parameters

methodName
Type: System..::..String
The name of the method or property to be invoked.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.
args
Type: array< System..::..Object >[]()[][]
The optional arguments for the invocation. If argument matchers are used, remember to use ItExpr rather than It.

Type Parameters

TResult
The type of return value from the expression.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Verify Overload
Moq.Protected Namespace


Verify Method (String, Times, Object[])

IProtectedMock<(Of <(<'TMock>)>)>..::..Verify Method (String, Times, array<Object>[]()[][])
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a verify for a void method with the given methodName, optionally specifying arguments for the method call. Use in conjuntion with the default Loose.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void Verify(
    string methodName,
    Times times,
    params Object[] args
)

Parameters

methodName
Type: System..::..String
The name of the void method to be verified.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.
args
Type: array< System..::..Object >[]()[][]
The optional arguments for the invocation. If argument matchers are used, remember to use ItExpr rather than It.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Verify Overload
Moq.Protected Namespace


VerifyGet(TProperty) Method

IProtectedMock<(Of <(<'TMock>)>)>..::..VerifyGet<(Of <(<'TProperty>)>)> Method
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a verify for an invocation on a property getter with the given propertyName. The invocation was not call the times specified by times.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void VerifyGet<TProperty>(
    string propertyName,
    Times times
)

Parameters

propertyName
Type: System..::..String
The name of the property.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.

Type Parameters

TProperty
The type of the property.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Moq.Protected Namespace


VerifySet(TProperty) Method

IProtectedMock<(Of <(<'TMock>)>)>..::..VerifySet<(Of <(<'TProperty>)>)> Method
IProtectedMock<(Of <(<'TMock>)>)> Interface See Also Send Feedback
Specifies a setup for an invocation on a property setter with the given propertyName.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
void VerifySet<TProperty>(
    string propertyName,
    Times times,
    Object value
)

Parameters

propertyName
Type: System..::..String
The name of the property.
times
Type: Moq..::..Times
The number of times a method is allowed to be called.
value
Type: System..::..Object
The property value.

Type Parameters

TProperty
The type of the property. If argument matchers are used, remember to use ItExpr rather than It.

Exceptions

Exception | Condition
Moq..::..MockException | The invocation was not call the times specified by times.

See Also

IProtectedMock<(Of <(<'TMock>)>)> Interface
Moq.Protected Namespace


ItExpr Class

ItExpr Class
Members See Also Send Feedback
Allows the specification of a matching condition for an argument in a protected member setup, rather than a specific argument value. "ItExpr" refers to the argument being matched.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class ItExpr

Remarks

Use this variant of argument matching instead of It for protected setups.

This class allows the setup to match a method invocation with an arbitrary value, with a value in a specified range, or even one that matches a given predicate, or null.

Inheritance Hierarchy

System..::..Object
Moq.Protected..::..ItExpr

See Also

ItExpr Members
Moq.Protected Namespace


ItExpr Members

[image]

Moq
ItExpr Members
ItExpr Class Methods See Also Send Feedback

The ItExpr type exposes the following members.

Methods

Name | Description
Is<(Of <<'(TValue>)>>) |
IsAny<(Of <<'(TValue>)>>) | Matches any value of the given TValue type.
IsInRange<(Of <<'(TValue>)>>) | Matches any value that is in the range specified.
IsNull<(Of <<'(TValue>)>>) | Matches a null value of the given TValue type.
IsRegex(String) | Matches a string argument if it matches the given regular expression pattern.
IsRegex(String, RegexOptions) | Matches a string argument if it matches the given regular expression pattern.

See Also

ItExpr Class
Moq.Protected Namespace


ItExpr Methods

[image]

Moq
ItExpr Methods
ItExpr Class See Also Send Feedback

The ItExpr type exposes the following members.

Methods

Name | Description
Is<(Of <<'(TValue>)>>) |
IsAny<(Of <<'(TValue>)>>) | Matches any value of the given TValue type.
IsInRange<(Of <<'(TValue>)>>) | Matches any value that is in the range specified.
IsNull<(Of <<'(TValue>)>>) | Matches a null value of the given TValue type.
IsRegex(String) | Matches a string argument if it matches the given regular expression pattern.
IsRegex(String, RegexOptions) | Matches a string argument if it matches the given regular expression pattern.

See Also

ItExpr Class
Moq.Protected Namespace


Is(TValue) Method

ItExpr..::..Is<(Of <(<'TValue>)>)> Method
ItExpr Class See Also Send Feedback

[Missing <summary> documentation for "M:Moq.Protected.ItExpr.Is``1(System.Linq.Expressions.Expression{System.Func`2})"]

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression Is<TValue>(
    Expression<Func> match
)

Parameters

match
Type: System.Linq.Expressions..::..Expression <(Of <(<' Func<(Of <(<'T, TResult>)>)> >)>)>

Type Parameters

TValue

See Also

ItExpr Class
Moq.Protected Namespace


IsAny(TValue) Method

ItExpr..::..IsAny<(Of <(<'TValue>)>)> Method
ItExpr Class Example See Also Send Feedback
Matches any value of the given TValue type.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression IsAny<TValue>()

Type Parameters

TValue
Type of the value.

Remarks

Typically used when the actual argument value for a method call is not relevant.

Examples

CopyC#
// Throws an exception for a call to Remove with any string value.
mock.Protected()
    .Setup("Remove", ItExpr.IsAny<string>())
    .Throws(new InvalidOperationException());

See Also

ItExpr Class
Moq.Protected Namespace


IsInRange(TValue) Method

ItExpr..::..IsInRange<(Of <(<'TValue>)>)> Method
ItExpr Class Example See Also Send Feedback
Matches any value that is in the range specified.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression IsInRange<TValue>(
    TValue from,
    TValue to,
    Range rangeKind
)
where TValue : IComparable

Parameters

from
Type: TValue
The lower bound of the range.
to
Type: TValue
The upper bound of the range.
rangeKind
Type: Moq..::..Range
The kind of range. See Range.

Type Parameters

TValue
Type of the argument to check.

Examples

The following example shows how to expect a method call with an integer argument within the 0..100 range.
CopyC#
mock.Protected()
    .Setup("HasInventory",
            ItExpr.IsAny<string>(),
            ItExpr.IsInRange(0, 100, Range.Inclusive))
    .Returns(false);

See Also

ItExpr Class
Moq.Protected Namespace


IsNull(TValue) Method

ItExpr..::..IsNull<(Of <(<'TValue>)>)> Method
ItExpr Class Example See Also Send Feedback
Matches a null value of the given TValue type.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression IsNull<TValue>()

Type Parameters

TValue
Type of the value.

Remarks

Required for protected mocks as the null value cannot be used directly as it prevents proper method overload selection.

Examples

CopyC#
// Throws an exception for a call to Remove with a null string value.
mock.Protected()
    .Setup("Remove", ItExpr.IsNull<string>())
    .Throws(new InvalidOperationException());

See Also

ItExpr Class
Moq.Protected Namespace


IsRegex Method

[image]

Moq
ItExpr..::..IsRegex Method
ItExpr Class See Also Send Feedback

Overload List

Name | Description
IsRegex(String) | Matches a string argument if it matches the given regular expression pattern.
IsRegex(String, RegexOptions) | Matches a string argument if it matches the given regular expression pattern.

See Also

ItExpr Class
ItExpr Members
Moq.Protected Namespace


IsRegex Method (String)

ItExpr..::..IsRegex Method (String)
ItExpr Class Example See Also Send Feedback
Matches a string argument if it matches the given regular expression pattern.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression IsRegex(
    string regex
)

Parameters

regex
Type: System..::..String
The pattern to use to match the string argument value.

Examples

The following example shows how to expect a call to a method where the string argument matches the given regular expression:
CopyC#
mock.Protected()
    .Setup("Check", ItExpr.IsRegex("[a-z]+"))
    .Returns(1);

See Also

ItExpr Class
IsRegex Overload
Moq.Protected Namespace


IsRegex Method (String, RegexOptions)

ItExpr..::..IsRegex Method (String, RegexOptions)
ItExpr Class Example See Also Send Feedback
Matches a string argument if it matches the given regular expression pattern.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression IsRegex(
    string regex,
    RegexOptions options
)

Parameters

regex
Type: System..::..String
The pattern to use to match the string argument value.
options
Type: System.Text.RegularExpressions..::..RegexOptions
The options used to interpret the pattern.

Examples

The following example shows how to expect a call to a method where the string argument matches the given regular expression, in a case insensitive way:
CopyC#
mock.Protected()
    .Setup("Check", ItExpr.IsRegex("[a-z]+", RegexOptions.IgnoreCase))
    .Returns(1);

See Also

ItExpr Class
IsRegex Overload
Moq.Protected Namespace


ProtectedExtension Class

ProtectedExtension Class
Members See Also Send Feedback
Enables the Protected() method on Mock<(Of <(<'T>)>)>, allowing setups to be set for protected members by using their name as a string, rather than strong-typing them which is not possible due to their visibility.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static class ProtectedExtension

Inheritance Hierarchy

System..::..Object
Moq.Protected..::..ProtectedExtension

See Also

ProtectedExtension Members
Moq.Protected Namespace


ProtectedExtension Members

[image]

Moq
ProtectedExtension Members
ProtectedExtension Class Methods See Also Send Feedback

The ProtectedExtension type exposes the following members.

Methods

Name | Description
Protected<(Of <<'(T>)>>) | Enable protected setups for the mock.

See Also

ProtectedExtension Class
Moq.Protected Namespace


ProtectedExtension Methods

[image]

Moq
ProtectedExtension Methods
ProtectedExtension Class See Also Send Feedback

The ProtectedExtension type exposes the following members.

Methods

Name | Description
Protected<(Of <<'(T>)>>) | Enable protected setups for the mock.

See Also

ProtectedExtension Class
Moq.Protected Namespace


Protected(T) Method

ProtectedExtension..::..Protected<(Of <(<'T>)>)> Method
ProtectedExtension Class See Also Send Feedback
Enable protected setups for the mock.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static IProtectedMock<T> Protected<T>(
    this Mock<T> mock
)
where T : class

Parameters

mock
Type: Moq..::..Mock <(Of <(<'T>)>)>
The mock to set the protected setups on.

Type Parameters

T
Mocked object type. Typically omitted as it can be inferred from the mock instance.

See Also

ProtectedExtension Class
Moq.Protected Namespace