Table of Contents

Class Assert

Namespace
Olve.Utilities.Assertions
Assembly
Olve.Utilities.dll

Provides a set of assertion methods.

public static class Assert
Inheritance
Assert
Inherited Members

Methods

IsEmpty<T>(IEnumerable<T>, string)

Throws an AssertionError if the collection is not empty.

[Conditional("DEBUG")]
public static void IsEmpty<T>(IEnumerable<T> collection, string message = "Collection should be empty.")

Parameters

collection IEnumerable<T>

The collection to check.

message string

The message to include in the exception.

Type Parameters

T

Type of elements in the collection.

Exceptions

AssertionError

Thrown if the collection is not empty.

IsNotEmpty<T>(IEnumerable<T>, string)

Throws an AssertionError if the collection is empty.

[Conditional("DEBUG")]
public static void IsNotEmpty<T>(IEnumerable<T> collection, string message = "Collection should not be empty.")

Parameters

collection IEnumerable<T>

The collection to check.

message string

The message to include in the exception.

Type Parameters

T

Type of elements in the collection.

Exceptions

AssertionError

Thrown if the collection is empty.

NotNull<T>(T?, string)

Throws an AssertionError if the value is null.

[Conditional("DEBUG")]
public static void NotNull<T>(T? value, string message = "Value cannot be null.") where T : class

Parameters

value T

Value to check.

message string

The message to include in the exception.

Type Parameters

T

Type of the value.

That(Func<bool>, string)

Throws an AssertionError if the assertion is false.

[Conditional("DEBUG")]
public static void That(Func<bool> assertion, string message)

Parameters

assertion Func<bool>

The assertion to check.

message string

The message to include in the exception.

Remarks

Is only executed in debug builds.

Exceptions

AssertionError

Thrown if the assertion is false.