Table of Contents

Class SomeItemsConstraint

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

SomeItemsConstraint applies another constraint to each item in a collection, succeeding if any of them succeeds.

public class SomeItemsConstraint : PrefixConstraint, IConstraint, IResolveConstraint
Inheritance
SomeItemsConstraint
Implements
Inherited Members

Constructors

SomeItemsConstraint(IConstraint)

Construct a SomeItemsConstraint on top of an existing constraint

public SomeItemsConstraint(IConstraint itemConstraint)

Parameters

itemConstraint IConstraint

Properties

DisplayName

The display name of this Constraint for use by ToString(). The default value is the name of the constraint with trailing "Constraint" removed. Derived classes may set this to another name in their constructors.

public override string DisplayName { get; }

Property Value

string

Methods

ApplyTo<TActual>(TActual)

Apply the item constraint to each item in the collection, succeeding if any item succeeds.

public override ConstraintResult ApplyTo<TActual>(TActual actual)

Parameters

actual TActual

Returns

ConstraintResult

Type Parameters

TActual

Using(IComparer)

Flag the constraint to use the supplied IComparer object.

public SomeItemsConstraint Using(IComparer comparer)

Parameters

comparer IComparer

The IComparer object to use.

Returns

SomeItemsConstraint

Self.

Using(IEqualityComparer)

Flag the constraint to use the supplied IEqualityComparer object.

public SomeItemsConstraint Using(IEqualityComparer comparer)

Parameters

comparer IEqualityComparer

The IComparer object to use.

Returns

SomeItemsConstraint

Self.

UsingPropertiesComparer()

Enables comparing of instance properties.

public SomeItemsConstraint UsingPropertiesComparer()

Returns

SomeItemsConstraint

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<T> object.

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

Parameters

comparer IComparer<T>

The IComparer object to use.

Returns

SomeItemsConstraint

Self.

Type Parameters

T

Using<T>(IEqualityComparer<T>)

Flag the constraint to use the supplied IEqualityComparer<T> object.

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

Parameters

comparer IEqualityComparer<T>

The IComparer object to use.

Returns

SomeItemsConstraint

Self.

Type Parameters

T

Using<T>(Comparison<T>)

Flag the constraint to use the supplied Comparison<T> object.

public SomeItemsConstraint Using<T>(Comparison<T> comparer)

Parameters

comparer Comparison<T>

The IComparer object to use.

Returns

SomeItemsConstraint

Self.

Type Parameters

T

Using<TCollectionType, TMemberType>(Func<TCollectionType, TMemberType, bool>)

Flag the constraint to use the supplied Func<T1, T2, TResult> object.

public SomeItemsConstraint Using<TCollectionType, TMemberType>(Func<TCollectionType, TMemberType, bool> comparison)

Parameters

comparison Func<TCollectionType, TMemberType, bool>

The comparison function to use.

Returns

SomeItemsConstraint

Self.

Type Parameters

TCollectionType

The type of the elements in the collection.

TMemberType

The type of the member.