Table of Contents

Class Asserts

Namespace
Garyon.Functions
Assembly
Garyon.dll

Provides assertion helpers for validating conditions and values.

public static class Asserts
Inheritance
Asserts
Inherited Members

Methods

Default<T>(T, string)

Asserts that the specified value is equal to its default value.

public static void Default<T>(T value, string expression = "")

Parameters

value T

The value to evaluate.

expression string

The expression text of the asserted value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when value is not the default value.

Equal<T>(T, T, string, string)

Asserts that two values are equal.

public static void Equal<T>(T actual, T expected, string actualExpression = "", string expectedExpression = "")

Parameters

actual T

The actual value.

expected T

The expected value.

actualExpression string

The expression text of the actual value.

expectedExpression string

The expression text of the expected value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when actual and expected are not equal.

False(bool, string)

Asserts that the specified condition is false.

public static void False(bool condition, string expression = "")

Parameters

condition bool

The condition to evaluate.

expression string

The expression text of the asserted condition.

Exceptions

AssertionException

Thrown when condition is true.

GreaterThanOrEqual<T>(T, T, string, string)

Asserts that the actual value is greater than or equal to the expected value.

public static void GreaterThanOrEqual<T>(T actual, T expected, string actualExpression = "", string expectedExpression = "") where T : IComparisonOperators<T, T, bool>

Parameters

actual T

The actual value.

expected T

The value that the actual value must be greater than or equal to.

actualExpression string

The expression text of the actual value.

expectedExpression string

The expression text of the expected value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when actual is less than expected.

GreaterThan<T>(T, T, string, string)

Asserts that the actual value is greater than the expected value.

public static void GreaterThan<T>(T actual, T expected, string actualExpression = "", string expectedExpression = "") where T : IComparisonOperators<T, T, bool>

Parameters

actual T

The actual value.

expected T

The value that the actual value must be greater than.

actualExpression string

The expression text of the actual value.

expectedExpression string

The expression text of the expected value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when actual is not greater than expected.

LessThanOrEqual<T>(T, T, string, string)

Asserts that the actual value is less than or equal to the expected value.

public static void LessThanOrEqual<T>(T actual, T expected, string actualExpression = "", string expectedExpression = "") where T : IComparisonOperators<T, T, bool>

Parameters

actual T

The actual value.

expected T

The value that the actual value must be less than or equal to.

actualExpression string

The expression text of the actual value.

expectedExpression string

The expression text of the expected value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when actual is greater than expected.

LessThan<T>(T, T, string, string)

Asserts that the actual value is less than the expected value.

public static void LessThan<T>(T actual, T expected, string actualExpression = "", string expectedExpression = "") where T : IComparisonOperators<T, T, bool>

Parameters

actual T

The actual value.

expected T

The value that the actual value must be less than.

actualExpression string

The expression text of the actual value.

expectedExpression string

The expression text of the expected value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when actual is not less than expected.

NotDefault<T>(T, string)

Asserts that the specified value is not equal to its default value.

public static void NotDefault<T>(T value, string expression = "")

Parameters

value T

The value to evaluate.

expression string

The expression text of the asserted value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when value is the default value.

NotEqual<T>(T, T, string, string)

Asserts that two values are not equal.

public static void NotEqual<T>(T actual, T expected, string actualExpression = "", string expectedExpression = "")

Parameters

actual T

The actual value.

expected T

The value that should not match the actual value.

actualExpression string

The expression text of the actual value.

expectedExpression string

The expression text of the expected value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when actual and expected are equal.

NotNull<T>(T?, string)

Asserts that the specified value is not null.

public static void NotNull<T>(T? value, string expression = "")

Parameters

value T

The value to evaluate.

expression string

The expression text of the asserted value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when value is null.

Null<T>(T?, string)

Asserts that the specified value is null.

public static void Null<T>(T? value, string expression = "")

Parameters

value T

The value to evaluate.

expression string

The expression text of the asserted value.

Type Parameters

T

The value type.

Exceptions

AssertionException

Thrown when value is not null.

OfType<T>(object?, string)

Asserts that the specified value is of the specified type.

public static T OfType<T>(object? value, string expression = "")

Parameters

value object

The value to evaluate.

expression string

The expression text of the asserted value.

Returns

T

Type Parameters

T

The expected type.

Exceptions

AssertionException

Thrown when value is not of type T.

True(bool, string)

Asserts that the specified condition is true.

public static void True(bool condition, string expression = "")

Parameters

condition bool

The condition to evaluate.

expression string

The expression text of the asserted condition.

Exceptions

AssertionException

Thrown when condition is false.