Assert.ThrowsExactly Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| ThrowsExactly<TException>(Func<Object>, Func<Exception,String>, String) |
Asserts that the delegate |
| ThrowsExactly<TException>(Func<Object>, Func<Exception,String>) |
Asserts that the delegate |
| ThrowsExactly<TException>(Func<Object>, String, String) |
Asserts that the delegate |
| ThrowsExactly<TException>(Func<Object>, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>, String) |
Asserts that the delegate |
| ThrowsExactly<TException>(Func<Object>, String, Object[]) |
Asserts that the delegate |
| ThrowsExactly<TException>(Action, String, String) |
Asserts that the delegate |
| ThrowsExactly<TException>(Action, Func<Exception,String>) |
Asserts that the delegate |
| ThrowsExactly<TException>(Action, Func<Exception,String>, String) |
Asserts that the delegate |
| ThrowsExactly<TException>(Action, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>, String) |
Asserts that the delegate |
| ThrowsExactly<TException>(Func<Object>, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>) |
Asserts that the delegate |
| ThrowsExactly<TException>(Action, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>) |
Asserts that the delegate |
| ThrowsExactly<TException>(Action, String, Object[]) |
Asserts that the delegate |
ThrowsExactly<TException>(Func<Object>, Func<Exception,String>, String)
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Func<object?> action, Func<Exception?,string> messageBuilder, string actionExpression = "") where TException : Exception;
static member ThrowsExactly : Func<obj> * Func<Exception, string> * string -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Func(Of Object), messageBuilder As Func(Of Exception, String), Optional actionExpression As String = "") As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
A func that takes the thrown Exception (or null if the action didn't throw any exception) to construct the message to include in the exception when action does not throws exception of type TException.
- actionExpression
- String
The syntactic expression of action as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Func<Object>, Func<Exception,String>)
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Func<object?> action, Func<Exception?,string> messageBuilder) where TException : Exception;
static member ThrowsExactly : Func<obj> * Func<Exception, string> -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Func(Of Object), messageBuilder As Func(Of Exception, String)) As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
A func that takes the thrown Exception (or null if the action didn't throw any exception) to construct the message to include in the exception when action does not throws exception of type TException.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Func<Object>, String, String)
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Func<object?> action, string? message = "", string actionExpression = "") where TException : Exception;
static member ThrowsExactly : Func<obj> * string * string -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Func(Of Object), Optional message As String = "", Optional actionExpression As String = "") As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- message
- String
The message to include in the exception when action does not throws exception of type TException.
- actionExpression
- String
The syntactic expression of action as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Func<Object>, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>, String)
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Func<object?> action, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertThrowsExactlyInterpolatedStringHandler<TException> message, string actionExpression = "") where TException : Exception;
static member ThrowsExactly : Func<obj> * AssertThrowsExactlyInterpolatedStringHandler * string -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Func(Of Object), ByRef message As Assert.AssertThrowsExactlyInterpolatedStringHandler(Of TException), Optional actionExpression As String = "") As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
The message to include in the exception when action does not throws exception of type TException.
- actionExpression
- String
The syntactic expression of action as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Func<Object>, String, Object[])
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Func<object?> action, string message = "", params object[] messageArgs) where TException : Exception;
static member ThrowsExactly : Func<obj> * string * obj[] -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Func(Of Object), Optional message As String = "", ParamArray messageArgs As Object()) As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- message
- String
The message to include in the exception when action does not throws exception of type TException.
- messageArgs
- Object[]
An array of parameters to use when formatting message.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Action, String, String)
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Action action, string? message = "", string actionExpression = "") where TException : Exception;
static member ThrowsExactly : Action * string * string -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Action, Optional message As String = "", Optional actionExpression As String = "") As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- action
- Action
Delegate to code to be tested and which is expected to throw exception.
- message
- String
The message to include in the exception when action does not throws exception of type TException.
- actionExpression
- String
The syntactic expression of action as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The exception that was thrown.
Exceptions
Thrown if action does not throws exception of type TException.
Applies to
ThrowsExactly<TException>(Action, Func<Exception,String>)
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Action action, Func<Exception?,string> messageBuilder) where TException : Exception;
static member ThrowsExactly : Action * Func<Exception, string> -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Action, messageBuilder As Func(Of Exception, String)) As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- action
- Action
Delegate to code to be tested and which is expected to throw exception.
A func that takes the thrown Exception (or null if the action didn't throw any exception) to construct the message to include in the exception when action does not throws exception of type TException.
Returns
The exception that was thrown.
Exceptions
Thrown if action does not throws exception of type TException.
Applies to
ThrowsExactly<TException>(Action, Func<Exception,String>, String)
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Action action, Func<Exception?,string> messageBuilder, string actionExpression = "") where TException : Exception;
static member ThrowsExactly : Action * Func<Exception, string> * string -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Action, messageBuilder As Func(Of Exception, String), Optional actionExpression As String = "") As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- action
- Action
Delegate to code to be tested and which is expected to throw exception.
A func that takes the thrown Exception (or null if the action didn't throw any exception) to construct the message to include in the exception when action does not throws exception of type TException.
- actionExpression
- String
The syntactic expression of action as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The exception that was thrown.
Exceptions
Thrown if action does not throws exception of type TException.
Applies to
ThrowsExactly<TException>(Action, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>, String)
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Action action, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertThrowsExactlyInterpolatedStringHandler<TException> message, string actionExpression = "") where TException : Exception;
static member ThrowsExactly : Action * AssertThrowsExactlyInterpolatedStringHandler * string -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Action, ByRef message As Assert.AssertThrowsExactlyInterpolatedStringHandler(Of TException), Optional actionExpression As String = "") As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- action
- Action
Delegate to code to be tested and which is expected to throw exception.
The message to include in the exception when action does not throws exception of type TException.
- actionExpression
- String
The syntactic expression of action as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Func<Object>, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>)
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Func<object?> action, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertThrowsExactlyInterpolatedStringHandler<TException> message) where TException : Exception;
static member ThrowsExactly : Func<obj> * AssertThrowsExactlyInterpolatedStringHandler -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Func(Of Object), ByRef message As Assert.AssertThrowsExactlyInterpolatedStringHandler(Of TException)) As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
The message to include in the exception when action does not throws exception of type TException.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Action, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>)
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Action action, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertThrowsExactlyInterpolatedStringHandler<TException> message) where TException : Exception;
static member ThrowsExactly : Action * AssertThrowsExactlyInterpolatedStringHandler -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Action, ByRef message As Assert.AssertThrowsExactlyInterpolatedStringHandler(Of TException)) As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- action
- Action
Delegate to code to be tested and which is expected to throw exception.
The message to include in the exception when action does not throws exception of type TException.
Returns
The exception that was thrown.
Applies to
ThrowsExactly<TException>(Action, String, Object[])
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
- Source:
- Assert.ThrowsException.cs
Asserts that the delegate action throws an exception of type TException
(and not of derived type) and throws AssertFailedException if code does not throws exception or throws
exception of type other than TException.
public static TException ThrowsExactly<TException>(Action action, string message = "", params object[] messageArgs) where TException : Exception;
static member ThrowsExactly : Action * string * obj[] -> 'Exception (requires 'Exception :> Exception)
Public Shared Function ThrowsExactly(Of TException As Exception) (action As Action, Optional message As String = "", ParamArray messageArgs As Object()) As TException
Type Parameters
- TException
The type of exception expected to be thrown.
Parameters
- action
- Action
Delegate to code to be tested and which is expected to throw exception.
- message
- String
The message to include in the exception when action does not throws exception of type TException.
- messageArgs
- Object[]
An array of parameters to use when formatting message.
Returns
The exception that was thrown.
Exceptions
Thrown if action does not throws exception of type TException.