This class holds additional functionality that can be validated on an exception.
The constructor.
Name | Description |
---|---|
exception | System.Exception The exception context. |
The exception Thrown.
Verify if a string contains another string. Throws exception if not.
Name | Description |
---|---|
propertyName | System.String The name of the string/property being verified. |
propertyValue | System.String Its value. |
substring | System.String The substring to verify for. |
Ensures that the exception has exactly the specified message.
Name | Description |
---|---|
message | System.String The expected exception message. |
Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: When the message is not exactly similar to the exception message.
The current instance of the ShouldThrow class so this can be chained with other asserts.
Ensures that the exception contains an inner exception of the specified type.
The current instance of the ShouldThrow class so this can be chained with other asserts.
Ensures that the exception contains the specified message.
Name | Description |
---|---|
message | System.String The expected exception message. |
Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: When the message is not part of the exception message.
The current instance of the ShouldThrow class so this can be chained with other asserts.
Ensures that the exception contains the specified stack trace.
Name | Description |
---|---|
stackTrace | System.String The stack trace. |
The current instance of the ShouldThrow class so this can be chained with other asserts.
Extensions for the MSTest Assertions.
Asserts that the delegate does not throw an exception.
Name | Description |
---|---|
assert | Microsoft.VisualStudio.TestTools.UnitTesting.Assert The assert class. |
action | System.Action Delegate to code to be tested and which is expected to throw exception. |
Asserts that the delegate does not throw an exception.
Name | Description |
---|---|
assert | Microsoft.VisualStudio.TestTools.UnitTesting.Assert The assert class. |
action | System.Func{System.Object} Delegate to code to be tested and which is expected to throw exception. |
Tests whether the code specified by delegate throws exception of type 'T'
Name | Description |
---|---|
assert | Microsoft.VisualStudio.TestTools.UnitTesting.Assert The assert class. |
action | System.Action Delegate to code to be tested and which is expected to throw exception. |
Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Thrown if does not throws exception of type .
The context assertion for further actions.
Tests whether the code specified by delegate throws exception of type 'T'
Name | Description |
---|---|
assert | Microsoft.VisualStudio.TestTools.UnitTesting.Assert The assert class. |
action | System.Func{System.Object} Delegate to code to be tested and which is expected to throw exception. |
Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Thrown if does not throws exception of type .
The context assertion for further actions.
Tests whether the code specified by delegate throws exact given exception/has inner exception of type (and not of derived type).
Name | Description |
---|---|
assert | Microsoft.VisualStudio.TestTools.UnitTesting.Assert The assert class. |
action | System.Action Delegate to code to be tested and which is expected to throw exception. |
Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Thrown if does not throws exception of type .
The type of exception expected to be thrown.
Tests whether the code specified by delegate throws exact exception/has inner exception of type (and not of derived type).
Name | Description |
---|---|
assert | Microsoft.VisualStudio.TestTools.UnitTesting.Assert The assert class. |
action | System.Func{System.Object} Delegate to code to be tested and which is expected to throw exception. |
Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Thrown if does not throws exception/contain inner-exception of type .
The type of exception expected to be thrown.