Table of Contents

Method Equivalent

Namespace
Xunit
Assembly
xunit.v3.assert.dll

Equivalent(object?, object?, bool)

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.

public static void Equivalent(object? expected, object? actual, bool strict = false)

Parameters

expected object

The expected value

actual object

The actual value

strict bool

A flag which enables strict comparison mode

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).