ActionAssertions.Throw Method
Overloads
| Name | Description |
|---|---|
| Throw<TException>() | Asserts that the action throws an exception of the specified type. |
| Throw<TException>(String) | Asserts that the action throws an exception of the specified type with the specified message. |
| Throw<TException>(String, Exception) | Asserts that the action throws an exception of the specified type with the specified message and inner exception. |
| Throw<TException>(TException) | Asserts that the action throws the exact specified exception instance. |
Throw<TException>()
Asserts that the action throws an exception of the specified type.
public ActionAssertionsChain<TException> Throw<TException>()
where TException : Exception;
Type Parameters
| Name | Description |
|---|---|
| TException | The expected exception type. |
Returns
ActionAssertionsChain<TException>
An ActionAssertionsChain<TException> containing the thrown exception.
Throw<TException>(String)
Asserts that the action throws an exception of the specified type with the specified message.
public ActionAssertionsChain<TException> Throw<TException>(string expectedMessage)
where TException : Exception;
Type Parameters
| Name | Description |
|---|---|
| TException | The expected exception type. |
Parameters
| Name | Type | Description |
|---|---|---|
| expectedMessage | String | The expected exception message. |
Returns
ActionAssertionsChain<TException>
An ActionAssertionsChain<TException> containing the thrown exception.
Throw<TException>(String, Exception)
Asserts that the action throws an exception of the specified type with the specified message and inner exception.
public ActionAssertionsChain<TException> Throw<TException>(string expectedMessage, Exception? expectedInnerException)
where TException : Exception;
Type Parameters
| Name | Description |
|---|---|
| TException | The expected exception type. |
Parameters
| Name | Type | Description |
|---|---|---|
| expectedMessage | String | The expected exception message. |
| expectedInnerException | Exception | The expected inner exception, or null to assert no inner exception. |
Returns
ActionAssertionsChain<TException>
An ActionAssertionsChain<TException> containing the thrown exception.
Throw<TException>(TException)
Asserts that the action throws the exact specified exception instance.
public ActionAssertionsChain<TException> Throw<TException>(TException expected)
where TException : Exception;
Type Parameters
| Name | Description |
|---|---|
| TException | The expected exception type. |
Parameters
| Name | Type | Description |
|---|---|---|
| expected | TException | The expected exception instance. |
Returns
ActionAssertionsChain<TException>
An ActionAssertionsChain<TException> containing the thrown exception.