Class SingletonSpecimenBuilderNodeStackAdapterCollection

Namespace: AutoFixture
Assembly: AutoFixture.dll

A collection of ISpecimenBuilderTransformation instances, which can be used to produce a stack of singleton ISpecimenBuilderNode instances at the root of any ISpecimenBuilderNode graph.

public class SingletonSpecimenBuilderNodeStackAdapterCollection : Collection<ISpecimenBuilderTransformation>, IList<ISpecimenBuilderTransformation>, ICollection<ISpecimenBuilderTransformation>, IList, ICollection, IReadOnlyList<ISpecimenBuilderTransformation>, IReadOnlyCollection<ISpecimenBuilderTransformation>, IEnumerable<ISpecimenBuilderTransformation>, IEnumerable

Inheritance

objectCollection<ISpecimenBuilderTransformation>SingletonSpecimenBuilderNodeStackAdapterCollection

Implements

IList<ISpecimenBuilderTransformation>, ICollection<ISpecimenBuilderTransformation>, IList, ICollection, IReadOnlyList<ISpecimenBuilderTransformation>, IReadOnlyCollection<ISpecimenBuilderTransformation>, IEnumerable<ISpecimenBuilderTransformation>, IEnumerable

Inherited Members

Collection<ISpecimenBuilderTransformation>.Add(ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.Clear(), Collection<ISpecimenBuilderTransformation>.CopyTo(ISpecimenBuilderTransformation[], int), Collection<ISpecimenBuilderTransformation>.Contains(ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.GetEnumerator(), Collection<ISpecimenBuilderTransformation>.IndexOf(ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.Insert(int, ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.Remove(ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.RemoveAt(int), Collection<ISpecimenBuilderTransformation>.ClearItems(), Collection<ISpecimenBuilderTransformation>.InsertItem(int, ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.RemoveItem(int), Collection<ISpecimenBuilderTransformation>.SetItem(int, ISpecimenBuilderTransformation), Collection<ISpecimenBuilderTransformation>.Count, Collection<ISpecimenBuilderTransformation>.Items, Collection<ISpecimenBuilderTransformation>.this[int], object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Extension Methods

CollectionFiller.AddMany<ISpecimenBuilderTransformation>(ICollection<ISpecimenBuilderTransformation>, Func<ISpecimenBuilderTransformation>, int)

Remarks

Apart from containing a collection of `ISpecimenBuilderTransformation` instances, the SingletonSpecimenBuilderNodeStackCollectionAdapter also holds a reference to a `ISpecimenBuilderNode` graph. Every time an ISpecimenBuilderTransformation instance is added to the collection, it is also applied to the graph by invoking `ISpecimenBuilder)` against the existing graph. This doesn't change the existing graph, but produces a new graph, which then replaces the previous graph. The current graph is always available via the `Graph` property.

For all mutating operations on the collection, the SingletonSpecimenBuilderNodeStackCollectionAdapter replaces its internal graph with a new graph that encapsulates the new state. The original graph is not mutated, but when a seemingly mutating method is invoked, the `GraphChanged` event is raised.

Constructors

SingletonSpecimenBuilderNodeStackAdapterCollection(ISpecimenBuilderNode, Func<ISpecimenBuilderNode, bool>, params ISpecimenBuilderTransformation[])

Initializes a new instance of the SingletonSpecimenBuilderNodeStackAdapterCollection class.

public SingletonSpecimenBuilderNodeStackAdapterCollection(ISpecimenBuilderNode graph, Func<ISpecimenBuilderNode, bool> wrappedGraphPredicate, params ISpecimenBuilderTransformation[] transformations)

Parameters

graph ISpecimenBuilderNode

The base graph upon which the contained ISpecimenBuilderTransformation are applied.

wrappedGraphPredicate Func<ISpecimenBuilderNode, bool>

A predicate which identifies the wrapped graph.

transformations ISpecimenBuilderTransformation[]

The transformations to apply to graph.

Remarks

The transformations and subsequent transformations added to the instance are applied to a base graph. The base graph is found by looking for a node within the graph where wrappedGraphPredicate returns true.

Properties

Graph

Gets the full graph.

public ISpecimenBuilderNode Graph { get; }

Property Value

ISpecimenBuilderNode

Methods

ClearItems()

Removes all items from the collection.

protected override void ClearItems()

Remarks

Since this is a potentially mutating operation it may raise the `GraphChanged` event.

InsertItem(int, ISpecimenBuilderTransformation)

Inserts an element into the collection at the specified index.

protected override void InsertItem(int index, ISpecimenBuilderTransformation item)

Parameters

index int

The zero-based index at which index should be inserted.

item ISpecimenBuilderTransformation

The item to insert.

Remarks

Since this is a mutating operation it raises the `GraphChanged` event.

OnGraphChanged(SpecimenBuilderNodeEventArgs)

Raises the GraphChanged event.

protected virtual void OnGraphChanged(SpecimenBuilderNodeEventArgs e)

Parameters

e SpecimenBuilderNodeEventArgs

The SpecimenBuilderNodeEventArgs instance containing the event data.

RemoveItem(int)

Removes the element at the specified index of the collection.

protected override void RemoveItem(int index)

Parameters

index int

The zero-based index of the element to remove.

Remarks

Since this is a mutating operation it raises the `GraphChanged` event.

SetItem(int, ISpecimenBuilderTransformation)

Replaces the element at the specified index.

protected override void SetItem(int index, ISpecimenBuilderTransformation item)

Parameters

index int

The zero-based index of the element to replace.

item ISpecimenBuilderTransformation

The new value for the element at the specified index.

Remarks

Since this is a mutating operation it raises the `GraphChanged` event.

GraphChanged

Occurs when this instance changes its internal view of the encapsulated ISpecimenBuilderNode graph.

public event EventHandler<SpecimenBuilderNodeEventArgs> GraphChanged

Event Type

EventHandler<SpecimenBuilderNodeEventArgs>

Remarks

When this instance performs a mutating action, it replaces its previously encapsulated `ISpecimenBuilderNode` graph with a new graph where the change has been applied. The event arguments raised with the event contains a reference to the new graph.