Table of Contents

Class Assume

Namespace
LfrlAnvil
Assembly
LfrlAnvil.Core.dll

Contains helper methods for ConditionalAttributeDEBUG assertions.

public static class Assume
Inheritance
Assume
Inherited Members

Remarks

See Assert(bool, string) for more information.

Methods

Conditional(bool, Action)

Invokes the provided assumption delegate when the specified condition evaluates to true.

[Conditional("DEBUG")]
public static void Conditional(bool condition, Action assumption)

Parameters

condition bool

Condition to evaluate.

assumption Action

Delegate to invoke conditionally when condition evaluates to true.

Conditional(bool, Action, Action)

Invokes the provided assumptionIfTrue delegate when the specified condition evaluates to true, otherwise invokes the provided assumptionIfFalse delegate.

[Conditional("DEBUG")]
public static void Conditional(bool condition, Action assumptionIfTrue, Action assumptionIfFalse)

Parameters

condition bool

Condition to evaluate.

assumptionIfTrue Action

Delegate to invoke conditionally when condition evaluates to true.

assumptionIfFalse Action

Delegate to invoke conditionally when condition evaluates to false.

ContainsAtLeast<T>(IEnumerable<T>, int, string)

Assumes that param contains at least count elements.

[Conditional("DEBUG")]
public static void ContainsAtLeast<T>(IEnumerable<T> param, int count, string paramName = "")

Parameters

param IEnumerable<T>

Collection to verify.

count int

Minimum expected number of elements.

paramName string

Optional name of the parameter.

Type Parameters

T

Element type.

ContainsAtMost<T>(IEnumerable<T>, int, string)

Assumes that param contains at most count elements.

[Conditional("DEBUG")]
public static void ContainsAtMost<T>(IEnumerable<T> param, int count, string paramName = "")

Parameters

param IEnumerable<T>

Collection to verify.

count int

Maximum expected number of elements.

paramName string

Optional name of the parameter.

Type Parameters

T

Element type.

ContainsExactly<T>(IEnumerable<T>, int, string)

Assumes that param contains exactly count elements.

[Conditional("DEBUG")]
public static void ContainsExactly<T>(IEnumerable<T> param, int count, string paramName = "")

Parameters

param IEnumerable<T>

Collection to verify.

count int

Exact expected number of elements.

paramName string

Optional name of the parameter.

Type Parameters

T

Element type.

ContainsInRange<T>(IEnumerable<T>, int, int, string)

Assumes that param contains between minCount and maxCount elements.

[Conditional("DEBUG")]
public static void ContainsInRange<T>(IEnumerable<T> param, int minCount, int maxCount, string paramName = "")

Parameters

param IEnumerable<T>

Collection to verify.

minCount int

Minimum expected number of elements.

maxCount int

Maximum expected number of elements.

paramName string

Optional name of the parameter.

Type Parameters

T

Element type.

Equals<T>(T, T?, string)

Assumes that param is equal to value.

[Conditional("DEBUG")]
public static void Equals<T>(T param, T? value, string paramName = "") where T : notnull

Parameters

param T

Value to verify.

value T

Value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

False(bool, string)

Assumes that the provided condition is false.

[Conditional("DEBUG")]
public static void False(bool condition, string description = "")

Parameters

condition bool

Condition to verify.

description string

Optional description of the error.

IsDefined<T>(T, string)

Assumes that paramEnum is defined.

[Conditional("DEBUG")]
public static void IsDefined<T>(T param, string paramName = "") where T : struct, Enum

Parameters

param T

Value to verify.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

Remarks

See IsDefined<TEnum>(TEnum) for more information.

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

Assumes that param is empty.

[Conditional("DEBUG")]
public static void IsEmpty<T>(IEnumerable<T> param, string paramName = "")

Parameters

param IEnumerable<T>

Collection to verify.

paramName string

Optional name of the parameter.

Type Parameters

T

Element type.

IsGreaterThanOrEqualTo<T>(T, T?, string)

Assumes that param is greater than or equal to value.

[Conditional("DEBUG")]
public static void IsGreaterThanOrEqualTo<T>(T param, T? value, string paramName = "")

Parameters

param T

Value to verify.

value T

Value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsGreaterThan<T>(T, T?, string)

Assumes that param is greater than value.

[Conditional("DEBUG")]
public static void IsGreaterThan<T>(T param, T? value, string paramName = "")

Parameters

param T

Value to verify.

value T

Value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsInExclusiveRange<T>(T, T, T, string)

Assumes that param is exclusively between min and max.

[Conditional("DEBUG")]
public static void IsInExclusiveRange<T>(T param, T min, T max, string paramName = "")

Parameters

param T

Value to verify.

min T

Minimum value to compare param to.

max T

Maximum value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsInRange<T>(T, T, T, string)

Assumes that param is between min and max.

[Conditional("DEBUG")]
public static void IsInRange<T>(T param, T min, T max, string paramName = "")

Parameters

param T

Value to verify.

min T

Minimum value to compare param to.

max T

Maximum value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsLessThanOrEqualTo<T>(T, T?, string)

Assumes that param is less than or equal to value.

[Conditional("DEBUG")]
public static void IsLessThanOrEqualTo<T>(T param, T? value, string paramName = "")

Parameters

param T

Value to verify.

value T

Value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsLessThan<T>(T, T?, string)

Assumes that param is less than value.

[Conditional("DEBUG")]
public static void IsLessThan<T>(T param, T? value, string paramName = "")

Parameters

param T

Value to verify.

value T

Value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

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

Assumes that param is not empty.

[Conditional("DEBUG")]
public static void IsNotEmpty<T>(IEnumerable<T> param, string paramName = "")

Parameters

param IEnumerable<T>

Collection to verify.

paramName string

Optional name of the parameter.

Type Parameters

T

Element type.

IsNotInExclusiveRange<T>(T, T, T, string)

Assumes that param is not exclusively between min and max.

[Conditional("DEBUG")]
public static void IsNotInExclusiveRange<T>(T param, T min, T max, string paramName = "")

Parameters

param T

Value to verify.

min T

Minimum value to compare param to.

max T

Maximum value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsNotInRange<T>(T, T, T, string)

Assumes that param is not between min and max.

[Conditional("DEBUG")]
public static void IsNotInRange<T>(T param, T min, T max, string paramName = "")

Parameters

param T

Value to verify.

min T

Minimum value to compare param to.

max T

Maximum value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsNotNull<T>(T?, string)

Assumes that param is not null.

[Conditional("DEBUG")]
public static void IsNotNull<T>(T? param, string paramName = "")

Parameters

param T

Value to verify.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

IsNull<T>(T?, string)

Assumes that param is null.

[Conditional("DEBUG")]
public static void IsNull<T>(T? param, string paramName = "")

Parameters

param T

Value to verify.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

NotEquals<T>(T, T?, string)

Assumes that param is not equal to value.

[Conditional("DEBUG")]
public static void NotEquals<T>(T param, T? value, string paramName = "") where T : notnull

Parameters

param T

Value to verify.

value T

Value to compare param to.

paramName string

Optional name of the parameter.

Type Parameters

T

Parameter type.

True(bool, string)

Assumes that the provided condition is true.

[Conditional("DEBUG")]
public static void True(bool condition, string description = "")

Parameters

condition bool

Condition to verify.

description string

Optional description of the error.

Unreachable(string?)

Assumes that this call is unreachable.

[Conditional("DEBUG")]
public static void Unreachable(string? description = null)

Parameters

description string

Optional description of the error.