Table of Contents

Class CollectionItemsEqualConstraint

Namespace
NUnit.Framework.Constraints
Assembly
nunit.framework.dll

CollectionItemsEqualConstraint is the abstract base class for all collection constraints that apply some notion of item equality as a part of their operation.

public abstract class CollectionItemsEqualConstraint : CollectionConstraint, IConstraint, IResolveConstraint
Inheritance
CollectionItemsEqualConstraint
Implements
Derived
Inherited Members

Constructors

CollectionItemsEqualConstraint()

Construct an empty CollectionConstraint

protected CollectionItemsEqualConstraint()

CollectionItemsEqualConstraint(object?)

Construct a CollectionConstraint

protected CollectionItemsEqualConstraint(object? arg)

Parameters

arg object

Properties

IgnoreCase

Flag the constraint to ignore case and return self.

public CollectionItemsEqualConstraint IgnoreCase { get; }

Property Value

CollectionItemsEqualConstraint

IgnoringCase

Get a flag indicating whether the user requested us to ignore case.

protected bool IgnoringCase { get; }

Property Value

bool

UsingExternalComparer

Get a flag indicating whether any external comparers are in use.

protected bool UsingExternalComparer { get; }

Property Value

bool

Methods

ItemsEqual(object?, object?)

Compares two collection members for equality

protected bool ItemsEqual(object? x, object? y)

Parameters

x object
y object

Returns

bool

Tally(IEnumerable)

Return a new CollectionTally for use in making tests

protected CollectionTally Tally(IEnumerable c)

Parameters

c IEnumerable

The collection to be included in the tally

Returns

CollectionTally

Using(IComparer)

Flag the constraint to use the supplied IComparer object.

public CollectionItemsEqualConstraint Using(IComparer comparer)

Parameters

comparer IComparer

The IComparer object to use.

Returns

CollectionItemsEqualConstraint

Using(IEqualityComparer)

Flag the constraint to use the supplied IEqualityComparer object.

public CollectionItemsEqualConstraint Using(IEqualityComparer comparer)

Parameters

comparer IEqualityComparer

The IComparer object to use.

Returns

CollectionItemsEqualConstraint

UsingPropertiesComparer()

Enables comparing of instance properties.

public CollectionItemsEqualConstraint UsingPropertiesComparer()

Returns

CollectionItemsEqualConstraint

Remarks

This allows comparing classes that don't implement IEquatable<T> without having to compare each property separately in own code.

Using<T>(IComparer<T>)

Flag the constraint to use the supplied IComparer object.

public CollectionItemsEqualConstraint Using<T>(IComparer<T> comparer)

Parameters

comparer IComparer<T>

The IComparer object to use.

Returns

CollectionItemsEqualConstraint

Type Parameters

T

Using<T>(IEqualityComparer<T>)

Flag the constraint to use the supplied IEqualityComparer object.

public CollectionItemsEqualConstraint Using<T>(IEqualityComparer<T> comparer)

Parameters

comparer IEqualityComparer<T>

The IComparer object to use.

Returns

CollectionItemsEqualConstraint

Type Parameters

T

Using<T>(Comparison<T>)

Flag the constraint to use the supplied Comparison object.

public CollectionItemsEqualConstraint Using<T>(Comparison<T> comparison)

Parameters

comparison Comparison<T>

The Comparison object to use.

Returns

CollectionItemsEqualConstraint

Type Parameters

T

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

Flag the constraint to use the supplied boolean-returning delegate.

public CollectionItemsEqualConstraint Using<T>(Func<T, T, bool> comparer)

Parameters

comparer Func<T, T, bool>

The supplied boolean-returning delegate to use.

Returns

CollectionItemsEqualConstraint

Type Parameters

T