A collection of distinct object instances. Every element represents a valid instance which is different from all the other elements in the collection (object equality).

Namespace:  MbUnit.Framework.ContractVerifiers
Assembly:  MbUnit (in MbUnit.dll) Version: 3.3.0.0 (3.3.610.0)

Syntax

C#
public class DistinctInstanceCollection<T> : IEnumerable<T>, 
	IEnumerable
Visual Basic (Declaration)
Public Class DistinctInstanceCollection(Of T) _
	Implements IEnumerable(Of T), IEnumerable

Type Parameters

T
The type of the object instances in the collection.

Remarks

Distinct instances are used by some contract verifiers such as CollectionContract<(Of <(TCollection, TItem>)>) to check for the correct implementation of the collection interface.

Use the default constructor followed by a list initializer.

CopyC#
var collection = new DistinctInstanceCollection<Foo>
{
    new Foo(1)
    new Foo(2),
    new Foo(3),
};

Or, use the single-parameter constructor to create a collection from an pre-existing enumeration.

CopyC#
var collection = new DistinctInstanceCollection<Foo>(Foo.GetThemAll());

Inheritance Hierarchy

System..::.Object
  MbUnit.Framework.ContractVerifiers..::.DistinctInstanceCollection<(Of <(T>)>)
    MbUnit.Framework.ContractVerifiers..::.InvalidValuesClass<(Of <(T>)>)

See Also