Specifies the exception to throw when the method is invoked.
Namespace:
Moq.LanguageAssembly: Moq (in Moq.dll) Version: 4.0.812.4 (4.0.0.0)
Syntax
| C# |
|---|
IThrowsResult Throws( Exception exception ) |
Parameters
- exception
- Type: 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());