Table of Contents

Class ExceptionAssertExtensions

Namespace
MADE.Testing
Assembly
MADE.Testing.dll

Defines a code assertion helper for exception-based scenarios.

public static class ExceptionAssertExtensions
Inheritance
ExceptionAssertExtensions
Inherited Members

Methods

ShouldNotThrow(Action)

Tests whether the specified action does not throw any exception and throws an assertion exception if it does.

public static void ShouldNotThrow(this Action action)

Parameters

action Action

The action to execute.

Exceptions

AssertFailedException

Thrown if the action throws an exception.

ShouldNotThrowAsync(Func<Task>)

Tests whether the specified asynchronous action does not throw any exception and throws an assertion exception if it does.

public static Task ShouldNotThrowAsync(this Func<Task> action)

Parameters

action Func<Task>

The asynchronous action to execute.

Returns

Task

Exceptions

AssertFailedException

Thrown if the action throws an exception.

ShouldThrowAsync<TException>(Func<Task>)

Tests whether the specified asynchronous action throws an exception of the given type and throws an assertion exception if it does not.

public static Task<TException> ShouldThrowAsync<TException>(this Func<Task> action) where TException : Exception

Parameters

action Func<Task>

The asynchronous action to execute.

Returns

Task<TException>

The exception that was thrown.

Type Parameters

TException

The type of exception expected to be thrown.

Exceptions

AssertFailedException

Thrown if the action does not throw an exception of type TException.

ShouldThrow<TException>(Action)

Tests whether the specified action throws an exception of the given type and throws an assertion exception if it does not.

public static TException ShouldThrow<TException>(this Action action) where TException : Exception

Parameters

action Action

The action to execute.

Returns

TException

The exception that was thrown.

Type Parameters

TException

The type of exception expected to be thrown.

Exceptions

AssertFailedException

Thrown if the action does not throw an exception of type TException.