Show / Hide Table of Contents

Class AssertThatNumeric

Provides static methods for making assertions on numeric values with descriptive failure messages.

Inheritance
object
AssertThatNumeric
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.Common.Testing
Assembly: Benday.Common.Testing.dll
Syntax
public static class AssertThatNumeric

Methods

| Edit this page View Source

AreApproximatelyEqual(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com