Table of Contents

Method EquivalentWithExclusions

Namespace
Xunit
Assembly
xunit.v3.assert.dll

EquivalentWithExclusions<T>(object?, T, params Expression<Func<T, object?>>[])

Verifies that two objects are equivalent, using a default comparer. This comparison is done without regard to type, and only inspects public property and field values for individual equality. Deep equivalence tests (meaning, property or fields which are themselves complex types) are supported. Members can be excluded from the comparison by passing them as expressions via exclusionExpressions (using lambda expressions).

public static void EquivalentWithExclusions<T>(object? expected, T actual, params Expression<Func<T, object?>>[] exclusionExpressions)

Parameters

expected object

The expected value

actual T

The actual value

exclusionExpressions Expression<Func<T, object>>[]

The expressions for exclusions

Type Parameters

T

The type of the actual value

EquivalentWithExclusions<T>(object?, T, bool, params Expression<Func<T, object?>>[])

Verifies that two objects are equivalent, using a default comparer. This comparison is done without regard to type, and only inspects public property and field values for individual equality. Deep equivalence tests (meaning, property or fields which are themselves complex types) are supported. Members can be excluded from the comparison by passing them as expressions via exclusionExpressions (using lambda expressions).

public static void EquivalentWithExclusions<T>(object? expected, T actual, bool strict, params Expression<Func<T, object?>>[] exclusionExpressions)

Parameters

expected object

The expected value

actual T

The actual value

strict bool

A flag which enables strict comparison mode

exclusionExpressions Expression<Func<T, object>>[]

The expressions for exclusions

Type Parameters

T

The type of the actual value

Remarks

With strict mode off, object comparison allows actual to have extra public members that aren't part of expected, and collection comparison allows actual to have more data in it than is present in expected; with strict mode on, those rules are tightened to require exact member list (for objects) or data (for collections).

EquivalentWithExclusions(object?, object?, params string[])

Verifies that two objects are equivalent, using a default comparer. This comparison is done without regard to type, and only inspects public property and field values for individual equality. Deep equivalence tests (meaning, property or fields which are themselves complex types) are supported. Members can be excluded from the comparison by passing them as expressions via exclusionExpressions (using "Member.SubMember.SubSubMember" form).

public static void EquivalentWithExclusions(object? expected, object? actual, params string[] exclusionExpressions)

Parameters

expected object

The expected value

actual object

The actual value

exclusionExpressions string[]

The expressions for exclusions. This should be provided in "Member.SubMember.SubSubMember" form for deep exclusions.

EquivalentWithExclusions(object?, object?, bool, params string[])

Verifies that two objects are equivalent, using a default comparer. This comparison is done without regard to type, and only inspects public property and field values for individual equality. Deep equivalence tests (meaning, property or fields which are themselves complex types) are supported. Members can be excluded from the comparison by passing them as expressions via exclusionExpressions (using "Member.SubMember.SubSubMember" form).

public static void EquivalentWithExclusions(object? expected, object? actual, bool strict, params string[] exclusionExpressions)

Parameters

expected object

The expected value

actual object

The actual value

strict bool

A flag which enables strict comparison mode

exclusionExpressions string[]

The expressions for exclusions. This should be provided in "Member1.Member2.Member3" form for deep exclusions.

Remarks

With strict mode off, object comparison allows actual to have extra public members that aren't part of expected, and collection comparison allows actual to have more data in it than is present in expected; with strict mode on, those rules are tightened to require exact member list (for objects) or data (for collections).