Show / Hide Table of Contents

Class NumericAssertExtensions

Provides fluent assertion extension methods for numeric values.

Inheritance
object
NumericAssertExtensions
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 NumericAssertExtensions

Methods

| Edit this page View Source

ShouldBeApproximatelyEqualTo(decimal, decimal, decimal, string)

Verifies that two decimal values are approximately equal within the specified tolerance.

Declaration
public static decimal ShouldBeApproximatelyEqualTo(this decimal actual, decimal expected, decimal tolerance, string message)
Parameters
Type Name Description
decimal actual

The actual value.

decimal expected

The expected value.

decimal tolerance

The tolerance for comparison.

string message

The message to display if the assertion fails.

Returns
Type Description
decimal

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the values are not approximately equal.

| Edit this page View Source

ShouldBeApproximatelyEqualTo(double, double, double, string)

Verifies that two floating-point values are approximately equal within the specified tolerance.

Declaration
public static double ShouldBeApproximatelyEqualTo(this double actual, double expected, double tolerance, string message)
Parameters
Type Name Description
double actual

The actual value.

double expected

The expected value.

double tolerance

The tolerance for comparison.

string message

The message to display if the assertion fails.

Returns
Type Description
double

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the values are not approximately equal.

| Edit this page View Source

ShouldBeApproximatelyEqualTo(float, float, float, string)

Verifies that two floating-point values are approximately equal within the specified tolerance.

Declaration
public static float ShouldBeApproximatelyEqualTo(this float actual, float expected, float tolerance, string message)
Parameters
Type Name Description
float actual

The actual value.

float expected

The expected value.

float tolerance

The tolerance for comparison.

string message

The message to display if the assertion fails.

Returns
Type Description
float

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the values are not approximately equal.

| Edit this page View Source

ShouldBeFinite(double, string)

Verifies that a double value is finite (not infinity or NaN).

Declaration
public static double ShouldBeFinite(this double actual, string message)
Parameters
Type Name Description
double actual

The actual value.

string message

The message to display if the assertion fails.

Returns
Type Description
double

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the value is not finite.

| Edit this page View Source

ShouldBeFinite(float, string)

Verifies that a float value is finite (not infinity or NaN).

Declaration
public static float ShouldBeFinite(this float actual, string message)
Parameters
Type Name Description
float actual

The actual value.

string message

The message to display if the assertion fails.

Returns
Type Description
float

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the value is not finite.

| Edit this page View Source

ShouldBeGreaterThanOrEqualTo<T>(T, T, string)

Verifies that a value is greater than or equal to the specified minimum.

Declaration
public static T ShouldBeGreaterThanOrEqualTo<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBeGreaterThan<T>(T, T, string)

Verifies that a value is greater than the specified minimum.

Declaration
public static T ShouldBeGreaterThan<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBeInRange<T>(T, T, T, string)

Verifies that a value is within the specified range (inclusive).

Declaration
public static T ShouldBeInRange<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBeLessThanOrEqualTo<T>(T, T, string)

Verifies that a value is less than or equal to the specified maximum.

Declaration
public static T ShouldBeLessThanOrEqualTo<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBeLessThan<T>(T, T, string)

Verifies that a value is less than the specified maximum.

Declaration
public static T ShouldBeLessThan<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBeNegative<T>(T, string)

Verifies that a value is negative (less than zero).

Declaration
public static T ShouldBeNegative<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBePositive<T>(T, string)

Verifies that a value is positive (greater than zero).

Declaration
public static T ShouldBePositive<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldBeZero<T>(T, string)

Verifies that a value is zero.

Declaration
public static T ShouldBeZero<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldNotBeInRange<T>(T, T, T, string)

Verifies that a value is not within the specified range (inclusive).

Declaration
public static T ShouldNotBeInRange<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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

ShouldNotBeNaN(double, string)

Verifies that a double value is not NaN (Not a Number).

Declaration
public static double ShouldNotBeNaN(this double actual, string message)
Parameters
Type Name Description
double actual

The actual value.

string message

The message to display if the assertion fails.

Returns
Type Description
double

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the value is NaN.

| Edit this page View Source

ShouldNotBeNaN(float, string)

Verifies that a float value is not NaN (Not a Number).

Declaration
public static float ShouldNotBeNaN(this float actual, string message)
Parameters
Type Name Description
float actual

The actual value.

string message

The message to display if the assertion fails.

Returns
Type Description
float

The actual value for method chaining.

Exceptions
Type Condition
AssertionException

Thrown when the value is NaN.

| Edit this page View Source

ShouldNotBeZero<T>(T, string)

Verifies that a value is not zero.

Declaration
public static T ShouldNotBeZero<T>(this 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.

Returns
Type Description
T

The actual value for method chaining.

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
In this article
Back to top Copyright © www.benday.com | info@benday.com