Table of Contents

Class EqualityAsserts

Namespace
Asserts
Assembly
xunit.v3.assert.dll
public class EqualityAsserts
Inheritance
EqualityAsserts
Inherited Members

Methods

Equal(DateTime, DateTime)

Verifies that two DateTime values are equal.

public static void Equal(DateTime expected, DateTime actual)

Parameters

expected DateTime

The expected value

actual DateTime

The value to be compared against

Examples

Add an example for this method ?

Contribution guide.

Equal(DateTime, DateTime, TimeSpan)

Verifies that two DateTime values are equal, within the precision given by precision.

public static void Equal(DateTime expected, DateTime actual, TimeSpan precision)

Parameters

expected DateTime

The expected value

actual DateTime

The value to be compared against

precision TimeSpan

The allowed difference in time where the two dates are considered equal

Examples

Add an example for this method ?

Contribution guide.

Equal(DateTimeOffset, DateTimeOffset)

Verifies that two DateTimeOffset values are equal.

public static void Equal(DateTimeOffset expected, DateTimeOffset actual)

Parameters

expected DateTimeOffset

The expected value

actual DateTimeOffset

The value to be compared against

Examples

Add an example for this method ?

Contribution guide.

Equal(DateTimeOffset, DateTimeOffset, TimeSpan)

Verifies that two DateTimeOffset values are equal, within the precision given by precision.

public static void Equal(DateTimeOffset expected, DateTimeOffset actual, TimeSpan precision)

Parameters

expected DateTimeOffset

The expected value

actual DateTimeOffset

The value to be compared against

precision TimeSpan

The allowed difference in time where the two dates are considered equal

Examples

Add an example for this method ?

Contribution guide.

Equal(decimal, decimal, int)

Verifies that two decimal values are equal, within the number of decimal places given by precision. The values are rounded before comparison.

public static void Equal(decimal expected, decimal actual, int precision)

Parameters

expected decimal

The expected value

actual decimal

The value to be compared against

precision int

The number of decimal places (valid values: 0-28)

Examples

Add an example for this method ?

Contribution guide.

Equal(double, double, double)

Verifies that two double values are equal, within the tolerance given by tolerance (positive or negative).

public static void Equal(double expected, double actual, double tolerance)

Parameters

expected double

The expected value

actual double

The value to be compared against

tolerance double

The allowed difference between values

Examples

Add an example for this method ?

Contribution guide.

Equal(double, double, int)

Verifies that two double values are equal, within the number of decimal places given by precision. The values are rounded before comparison.

public static void Equal(double expected, double actual, int precision)

Parameters

expected double

The expected value

actual double

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

Examples

Add an example for this method ?

Contribution guide.

Equal(double, double, int, MidpointRounding)

Verifies that two double values are equal, within the number of decimal places given by precision. The values are rounded before comparison. The rounding method to use is given by rounding

public static void Equal(double expected, double actual, int precision, MidpointRounding rounding)

Parameters

expected double

The expected value

actual double

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

rounding MidpointRounding

Rounding method to use to process a number that is midway between two numbers

Examples

Add an example for this method ?

Contribution guide.

Equal(float, float, int)

Verifies that two float values are equal, within the number of decimal places given by precision. The values are rounded before comparison.

public static void Equal(float expected, float actual, int precision)

Parameters

expected float

The expected value

actual float

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

Examples

Add an example for this method ?

Contribution guide.

Equal(float, float, int, MidpointRounding)

Verifies that two float values are equal, within the number of decimal places given by precision. The values are rounded before comparison. The rounding method to use is given by rounding

public static void Equal(float expected, float actual, int precision, MidpointRounding rounding)

Parameters

expected float

The expected value

actual float

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

rounding MidpointRounding

Rounding method to use to process a number that is midway between two numbers

Examples

Add an example for this method ?

Contribution guide.

Equal(float, float, float)

Verifies that two float values are equal, within the tolerance given by tolerance (positive or negative).

public static void Equal(float expected, float actual, float tolerance)

Parameters

expected float

The expected value

actual float

The value to be compared against

tolerance float

The allowed difference between values

Examples

Add an example for this method ?

Contribution guide.

Equal<T>(T, T)

Verifies that two objects are equal, using a default comparer.

public static void Equal<T>(T expected, T actual)

Parameters

expected T

The expected value

actual T

The value to be compared against

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

Equal<T>(T, T, IEqualityComparer<T>)

Verifies that two objects are equal, using a custom equatable comparer.

public static void Equal<T>(T expected, T actual, IEqualityComparer<T> comparer)

Parameters

expected T

The expected value

actual T

The value to be compared against

comparer IEqualityComparer<T>

The comparer used to compare the two objects

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

Equal<T>(T, T, Func<T, T, bool>)

Verifies that two objects are equal, using a custom comparer function.

public static void Equal<T>(T expected, T actual, Func<T, T, bool> comparer)

Parameters

expected T

The expected value

actual T

The value to be compared against

comparer Func<T, T, bool>

The comparer used to compare the two objects

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

Equal<T>(T[], T[])

Verifies that two arrays of un-managed type T are equal, using Span<T>.SequenceEqual. This can be significantly faster than generic enumerables, when the collections are actually equal, because the system can optimize packed-memory comparisons for value type arrays.

public static void Equal<T>(T[] expected, T[] actual) where T : unmanaged, IEquatable<T>

Parameters

expected T[]

The expected value

actual T[]

The value to be compared against

Type Parameters

T

The type of items whose arrays are to be compared

Examples

Add an example for this method ?

Contribution guide.

Remarks

If SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) fails, a call to Assert.Equal<T>(T, T) is made, to provide a more meaningful error message.

NotEqual(decimal, decimal, int)

Verifies that two decimal values are not equal, within the number of decimal places given by precision.

public static void NotEqual(decimal expected, decimal actual, int precision)

Parameters

expected decimal

The expected value

actual decimal

The value to be compared against

precision int

The number of decimal places (valid values: 0-28)

Examples

Add an example for this method ?

Contribution guide.

NotEqual(double, double, double)

Verifies that two double values are not equal, within the tolerance given by tolerance (positive or negative).

public static void NotEqual(double expected, double actual, double tolerance)

Parameters

expected double

The expected value

actual double

The value to be compared against

tolerance double

The allowed difference between values

Examples

Add an example for this method ?

Contribution guide.

NotEqual(double, double, int)

Verifies that two double values are not equal, within the number of decimal places given by precision.

public static void NotEqual(double expected, double actual, int precision)

Parameters

expected double

The expected value

actual double

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

Examples

Add an example for this method ?

Contribution guide.

NotEqual(double, double, int, MidpointRounding)

Verifies that two double values are not equal, within the number of decimal places given by precision. The values are rounded before comparison. The rounding method to use is given by rounding

public static void NotEqual(double expected, double actual, int precision, MidpointRounding rounding)

Parameters

expected double

The expected value

actual double

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

rounding MidpointRounding

Rounding method to use to process a number that is midway between two numbers

Examples

Add an example for this method ?

Contribution guide.

NotEqual(float, float, int)

Verifies that two float values are not equal, within the number of decimal places given by precision.

public static void NotEqual(float expected, float actual, int precision)

Parameters

expected float

The expected value

actual float

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

Examples

Add an example for this method ?

Contribution guide.

NotEqual(float, float, int, MidpointRounding)

Verifies that two float values are not equal, within the number of decimal places given by precision. The values are rounded before comparison. The rounding method to use is given by rounding

public static void NotEqual(float expected, float actual, int precision, MidpointRounding rounding)

Parameters

expected float

The expected value

actual float

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

rounding MidpointRounding

Rounding method to use to process a number that is midway between two numbers

Examples

Add an example for this method ?

Contribution guide.

NotEqual(float, float, float)

Verifies that two float values are not equal, within the tolerance given by tolerance (positive or negative).

public static void NotEqual(float expected, float actual, float tolerance)

Parameters

expected float

The expected value

actual float

The value to be compared against

tolerance float

The allowed difference between values

Examples

Add an example for this method ?

Contribution guide.

NotEqual<T>(T, T)

Verifies that two objects are not equal, using a default comparer.

public static void NotEqual<T>(T expected, T actual)

Parameters

expected T

The expected object

actual T

The actual object

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

NotEqual<T>(T, T, IEqualityComparer<T>)

Verifies that two objects are not equal, using a custom equality comparer.

public static void NotEqual<T>(T expected, T actual, IEqualityComparer<T> comparer)

Parameters

expected T

The expected object

actual T

The actual object

comparer IEqualityComparer<T>

The comparer used to examine the objects

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

NotEqual<T>(T, T, Func<T, T, bool>)

Verifies that two objects are not equal, using a custom equality comparer function.

public static void NotEqual<T>(T expected, T actual, Func<T, T, bool> comparer)

Parameters

expected T

The expected object

actual T

The actual object

comparer Func<T, T, bool>

The comparer used to examine the objects

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

NotEqual<T>(T[], T[])

Verifies that two arrays of un-managed type T are not equal, using Span<T>.SequenceEqual.

public static void NotEqual<T>(T[] expected, T[] actual) where T : unmanaged, IEquatable<T>

Parameters

expected T[]

The expected value

actual T[]

The value to be compared against

Type Parameters

T

The type of items whose arrays are to be compared

Examples

Add an example for this method ?

Contribution guide.

NotStrictEqual<T>(T, T)

Verifies that two objects are strictly not equal, using the type's default comparer.

public static void NotStrictEqual<T>(T expected, T actual)

Parameters

expected T

The expected object

actual T

The actual object

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.

StrictEqual<T>(T, T)

Verifies that two objects are strictly equal, using the type's default comparer.

public static void StrictEqual<T>(T expected, T actual)

Parameters

expected T

The expected value

actual T

The value to be compared against

Type Parameters

T

The type of the objects to be compared

Examples

Add an example for this method ?

Contribution guide.