Class AssertThatNumeric
Provides static methods for making assertions on numeric values with descriptive failure messages.
Inherited Members
Namespace: Benday.Common.Testing
Assembly: Benday.Common.Testing.dll
Syntax
public static class AssertThatNumeric
Methods
| Edit this page View SourceAreApproximatelyEqual(decimal, decimal, decimal, string)
Verifies that two decimal values are approximately equal within the specified tolerance.
Declaration
public static void AreApproximatelyEqual(decimal expected, decimal actual, decimal tolerance, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | expected | The expected value. |
| decimal | actual | The actual value. |
| decimal | tolerance | The tolerance for comparison. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the values are not approximately equal. |
AreApproximatelyEqual(double, double, double, string)
Verifies that two floating-point values are approximately equal within the specified tolerance.
Declaration
public static void AreApproximatelyEqual(double expected, double actual, double tolerance, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| double | expected | The expected value. |
| double | actual | The actual value. |
| double | tolerance | The tolerance for comparison. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the values are not approximately equal. |
AreApproximatelyEqual(float, float, float, string)
Verifies that two floating-point values are approximately equal within the specified tolerance.
Declaration
public static void AreApproximatelyEqual(float expected, float actual, float tolerance, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| float | expected | The expected value. |
| float | actual | The actual value. |
| float | tolerance | The tolerance for comparison. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the values are not approximately equal. |
IsFinite(double, string)
Verifies that a double value is finite (not infinity or NaN).
Declaration
public static void IsFinite(double actual, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| double | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is not finite. |
IsFinite(float, string)
Verifies that a float value is finite (not infinity or NaN).
Declaration
public static void IsFinite(float actual, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| float | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is not finite. |
IsGreaterThanOrEqualTo<T>(T, T, string)
Verifies that a value is greater than or equal to the specified minimum.
Declaration
public static void IsGreaterThanOrEqualTo<T>(T actual, T minimum, string message) where T : IComparable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| T | minimum | The minimum value (inclusive). |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of values to compare. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the actual value is not greater than or equal to the minimum. |
IsGreaterThan<T>(T, T, string)
Verifies that a value is greater than the specified minimum.
Declaration
public static void IsGreaterThan<T>(T actual, T minimum, string message) where T : IComparable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| T | minimum | The minimum value (exclusive). |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of values to compare. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the actual value is not greater than the minimum. |
IsInRange<T>(T, T, T, string)
Verifies that a value is within the specified range (inclusive).
Declaration
public static void IsInRange<T>(T actual, T minimum, T maximum, string message) where T : IComparable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| T | minimum | The minimum value (inclusive). |
| T | maximum | The maximum value (inclusive). |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of values to compare. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the actual value is not within the range. |
IsLessThanOrEqualTo<T>(T, T, string)
Verifies that a value is less than or equal to the specified maximum.
Declaration
public static void IsLessThanOrEqualTo<T>(T actual, T maximum, string message) where T : IComparable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| T | maximum | The maximum value (inclusive). |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of values to compare. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the actual value is not less than or equal to the maximum. |
IsLessThan<T>(T, T, string)
Verifies that a value is less than the specified maximum.
Declaration
public static void IsLessThan<T>(T actual, T maximum, string message) where T : IComparable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| T | maximum | The maximum value (exclusive). |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of values to compare. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the actual value is not less than the maximum. |
IsNegative<T>(T, string)
Verifies that a value is negative (less than zero).
Declaration
public static void IsNegative<T>(T actual, string message) where T : IComparable<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is not negative. |
IsNotInRange<T>(T, T, T, string)
Verifies that a value is not within the specified range (inclusive).
Declaration
public static void IsNotInRange<T>(T actual, T minimum, T maximum, string message) where T : IComparable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| T | minimum | The minimum value (inclusive). |
| T | maximum | The maximum value (inclusive). |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of values to compare. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the actual value is within the range. |
IsNotNaN(double, string)
Verifies that a double value is not NaN (Not a Number).
Declaration
public static void IsNotNaN(double actual, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| double | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is NaN. |
IsNotNaN(float, string)
Verifies that a float value is not NaN (Not a Number).
Declaration
public static void IsNotNaN(float actual, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| float | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is NaN. |
IsNotZero<T>(T, string)
Verifies that a value is not zero.
Declaration
public static void IsNotZero<T>(T actual, string message) where T : IComparable<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is zero. |
IsPositive<T>(T, string)
Verifies that a value is positive (greater than zero).
Declaration
public static void IsPositive<T>(T actual, string message) where T : IComparable<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is not positive. |
IsZero<T>(T, string)
Verifies that a value is zero.
Declaration
public static void IsZero<T>(T actual, string message) where T : IComparable<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| T | actual | The actual value. |
| string | message | The message to display if the assertion fails. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| AssertionException | Thrown when the value is not zero. |