Partilhar via


ExpectedExceptionBaseAttribute Class

Definition

Base class for attributes that specify to expect an exception from a unit test

public ref class ExpectedExceptionBaseAttribute abstract : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)]
public abstract class ExpectedExceptionBaseAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)>]
type ExpectedExceptionBaseAttribute = class
    inherit Attribute
Public MustInherit Class ExpectedExceptionBaseAttribute
Inherits Attribute
Inheritance
ExpectedExceptionBaseAttribute
Derived
Attributes

Constructors

ExpectedExceptionBaseAttribute()

Initializes a new instance of the ExpectedExceptionBaseAttribute class with a default no-exception message

ExpectedExceptionBaseAttribute(String)

Initializes a new instance of the ExpectedExceptionBaseAttribute class with a no-exception message

Properties

NoExceptionMessage

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

SpecifiedNoExceptionMessage

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

TestContext

Methods

RethrowIfAssertException(Exception)

Rethrow the exception if it is an AssertFailedException or an AssertInconclusiveException

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.

Applies to