Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
ThrowsExactly<TException>(Func<Object>, String, Object[]) |
Asserts that the delegate |
ThrowsExactly<TException>(Action, String, Object[]) |
Asserts that the delegate |
ThrowsExactly<TException>(Func<Object>, Func<Exception,String>) |
Asserts that the delegate |
ThrowsExactly<TException>(Func<Object>, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>) |
Asserts that the delegate |
ThrowsExactly<TException>(Action, Func<Exception,String>) |
Asserts that the delegate |
ThrowsExactly<TException>(Action, Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>) |
Asserts that the delegate |
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
The type of exception expected to be thrown.
The message to include in the exception when action
does not throws exception of type TException
.
An array of parameters to use when formatting message
.
The exception that was thrown.
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
The type of exception expected to be thrown.
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
.
An array of parameters to use when formatting message
.
The exception that was thrown.
Thrown if action
does not throws exception of type TException
.
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
The type of exception expected to be thrown.
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
.
The exception that was thrown.
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
The type of exception expected to be thrown.
The message to include in the exception when action
does not throws exception of type TException
.
The exception that was thrown.
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
The type of exception expected to be thrown.
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
.
The exception that was thrown.
Thrown if action
does not throws exception of type TException
.
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
The type of exception expected to be thrown.
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
.
The exception that was thrown.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in