Verifies that a block of code throws an exception of a particular type; and that
the exception has an inner exception of a particular type.
Namespace:
MbUnit.FrameworkAssembly: MbUnit (in MbUnit.dll) Version: 3.3.0.0 (3.3.459.0)
Syntax
| C# |
|---|
public static Exception Throws( Type expectedExceptionType, Type expectedInnerExceptionType, Action action ) |
| Visual Basic (Declaration) |
|---|
Public Shared Function Throws ( _ expectedExceptionType As Type, _ expectedInnerExceptionType As Type, _ action As Action _ ) As Exception |
Parameters
- expectedExceptionType
- Type: System..::.Type
The expected exception type.
- expectedInnerExceptionType
- Type: System..::.Type
The expected inner exception type, or null to ignore the inner exception.
- action
- Type: Gallio.Common..::.Action
The action delegate to evaluate.
Return Value
The exception that was thrown.
Remarks
If the block of code throws a subtype of the expected exception types then this method will still succeed.
This method returns the exception that was caught. To verify additional properties of the exception, such as the exception message, follow up this assertion with additional ones that verify these properties of the exception object that was returned.
Exceptions
| Exception | Condition |
|---|---|
| System..::.ArgumentNullException | Thrown if expectedExceptionType or action is null. |
| Gallio.Framework.Assertions..::.AssertionException | Thrown if the verification failed unless the current AssertionFailureBehavior indicates otherwise. |
