Table of Contents

Class CollectionTracker<T>

Namespace
Xunit.Sdk
Assembly
xunit.v3.assert.dll

A utility class that can be used to wrap enumerables to prevent double enumeration. It offers the ability to safely print parts of the collection when failures are encountered, as well as some static versions of the printing functionality.

public sealed class CollectionTracker<T> : CollectionTracker, IDisposable, IEnumerable<T>, IEnumerable

Type Parameters

T
Inheritance
CollectionTracker<T>
Implements
Inherited Members
Extension Methods
Xunit.Sdk.CollectionTrackerExtensions.AsTracker``1(System.Collections.Generic.IEnumerable{``0})
Xunit.Sdk.CollectionTrackerExtensions.AsTracker(System.Collections.IEnumerable)
Xunit.Sdk.CollectionTrackerExtensions.GetEnumerator(Xunit.Sdk.CollectionTracker)

Properties

IterationCount

Gets the number of iterations that have happened so far.

Methods

Dispose()
FormatIndexedMismatch(int, int, int?, out int?, int)

Formats the collection when you have a mismatched index. The formatted result will be the section of the collection from startIndex to endIndex. These indices are usually obtained by calling GetMismatchExtents(int?, out int, out int).

FormatIndexedMismatch(int?, out int?, int)

Formats the collection when you have a mismatched index. The formatted result will be the section of the collection surrounded by the mismatched item.

FormatIndexedMismatch(ReadOnlySpan<T>, int?, out int?, int)

Formats a span with a mismatched index.

FormatStart(IEnumerable<T>, int)

Formats the beginning part of a collection.

FormatStart(int)

Formats the beginning part of the collection.

FormatStart(ReadOnlySpan<T>, int)

Formats the beginning part of a span.

GetEnumerator()
GetMismatchExtents(int?, out int, out int)

Gets the extents to print when you find a mismatched index, in the form of a startIndex and endIndex. If the mismatched index is null, the extents will start at index 0.

GetSafeEnumerator()

Gets a safe version of IEnumerator that prevents double enumeration and does all the necessary tracking required for collection formatting. Should should be the same value returned by GetEnumerator(), except non-generic.

TypeAt(int?)

Gets the full name of the type of the element at the given index, if known. Since this uses the item cache produced by enumeration, it may return null when we haven't enumerated enough to see the given element, or if we enumerated so much that the item has left the cache, or if the item at the given index is null. It will also return null when the index is null.

Wrap(IEnumerable<T>)

Wraps the given collection inside of a CollectionTracker<T>.