ExpectedExceptionAttribute ExpectedExceptionAttribute ExpectedExceptionAttribute Class

Definition

Attribute that specifies to expect an exception of the specified type

[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)]
public sealed class ExpectedExceptionAttribute : Microsoft.VisualStudio.TestTools.UnitTesting.ExpectedExceptionBaseAttribute
type ExpectedExceptionAttribute = class
    inherit ExpectedExceptionBaseAttribute
Public NotInheritable Class ExpectedExceptionAttribute
Inherits ExpectedExceptionBaseAttribute
Inheritance
ExpectedExceptionAttributeExpectedExceptionAttributeExpectedExceptionAttribute
Attributes

Constructors

ExpectedExceptionAttribute(Type) ExpectedExceptionAttribute(Type) ExpectedExceptionAttribute(Type)

Initializes a new instance of the ExpectedExceptionAttribute class with the expected type

ExpectedExceptionAttribute(Type, String) ExpectedExceptionAttribute(Type, String) ExpectedExceptionAttribute(Type, String)

Initializes a new instance of the ExpectedExceptionAttribute class with the expected type and the message to include when no exception is thrown by the test.

Properties

AllowDerivedTypes AllowDerivedTypes AllowDerivedTypes

Gets or sets a value indicating whether to allow types derived from the type of the expected exception to qualify as expected

ExceptionType ExceptionType ExceptionType

Gets a value indicating the Type of the expected exception

NoExceptionMessage NoExceptionMessage NoExceptionMessage

Gets the message to include in the test result if the test fails due to not throwing an exception

(Inherited from ExpectedExceptionBaseAttribute)
SpecifiedNoExceptionMessage SpecifiedNoExceptionMessage SpecifiedNoExceptionMessage

Gets the message to include in the test result if the test fails due to not throwing an exception

(Inherited from ExpectedExceptionBaseAttribute)

Methods

RethrowIfAssertException(Exception) RethrowIfAssertException(Exception) RethrowIfAssertException(Exception)

Rethrow the exception if it is an AssertFailedException or an AssertInconclusiveException

(Inherited from ExpectedExceptionBaseAttribute)
Verify(Exception) Verify(Exception) Verify(Exception)

Determines whether the exception is expected. If the method returns, then it is understood that the exception was expected. If the method throws an exception, then it is understood that the exception was not expected, and the thrown exception's message is included in the test result. The Assert class can be used for convenience. If Inconclusive() is used and the assertion fails, then the test outcome is set to Inconclusive.

(Inherited from ExpectedExceptionBaseAttribute)

Applies to