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
conditionboolCondition to evaluate.
assumptionActionDelegate to invoke conditionally when
conditionevaluates 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
conditionboolCondition to evaluate.
assumptionIfTrueActionDelegate to invoke conditionally when
conditionevaluates to true.assumptionIfFalseActionDelegate to invoke conditionally when
conditionevaluates 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
paramIEnumerable<T>Collection to verify.
countintMinimum expected number of elements.
paramNamestringOptional name of the parameter.
Type Parameters
TElement 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
paramIEnumerable<T>Collection to verify.
countintMaximum expected number of elements.
paramNamestringOptional name of the parameter.
Type Parameters
TElement 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
paramIEnumerable<T>Collection to verify.
countintExact expected number of elements.
paramNamestringOptional name of the parameter.
Type Parameters
TElement 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
paramIEnumerable<T>Collection to verify.
minCountintMinimum expected number of elements.
maxCountintMaximum expected number of elements.
paramNamestringOptional name of the parameter.
Type Parameters
TElement 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
paramTValue to verify.
valueTValue to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter type.
False(bool, string)
Assumes that the provided condition is false.
[Conditional("DEBUG")]
public static void False(bool condition, string description = "")
Parameters
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
paramTValue to verify.
paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramIEnumerable<T>Collection to verify.
paramNamestringOptional name of the parameter.
Type Parameters
TElement 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
paramTValue to verify.
valueTValue to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
valueTValue to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
minTMinimum value to compare
paramto.maxTMaximum value to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
minTMinimum value to compare
paramto.maxTMaximum value to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
valueTValue to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
valueTValue to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramIEnumerable<T>Collection to verify.
paramNamestringOptional name of the parameter.
Type Parameters
TElement 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
paramTValue to verify.
minTMinimum value to compare
paramto.maxTMaximum value to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
minTMinimum value to compare
paramto.maxTMaximum value to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter type.
IsNotNull<T>(T?, string)
Assumes that param is not null.
[Conditional("DEBUG")]
public static void IsNotNull<T>(T? param, string paramName = "")
Parameters
paramTValue to verify.
paramNamestringOptional name of the parameter.
Type Parameters
TParameter type.
IsNull<T>(T?, string)
Assumes that param is null.
[Conditional("DEBUG")]
public static void IsNull<T>(T? param, string paramName = "")
Parameters
paramTValue to verify.
paramNamestringOptional name of the parameter.
Type Parameters
TParameter 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
paramTValue to verify.
valueTValue to compare
paramto.paramNamestringOptional name of the parameter.
Type Parameters
TParameter type.
True(bool, string)
Assumes that the provided condition is true.
[Conditional("DEBUG")]
public static void True(bool condition, string description = "")
Parameters
Unreachable(string?)
Assumes that this call is unreachable.
[Conditional("DEBUG")]
public static void Unreachable(string? description = null)
Parameters
descriptionstringOptional description of the error.