Class TestTransformer<T>
A pass-through transformer for use in tests, examples, and benchmarks. Returns each item unchanged, with no transformation applied.
public class TestTransformer<T> : TransformerBase<T, T, Report>, ITransformWithProgressAndCancellationAsync<T, T, Report>, ITransformWithCancellationAsync<T, T>, ITransformWithProgressAsync<T, T, Report>, ITransformAsync<T, T>
Type Parameters
TThe type of item to transform.
- Inheritance
-
TransformerBase<T, T, Report>TestTransformer<T>
- Implements
-
ITransformWithProgressAndCancellationAsync<T, T, Report>ITransformWithCancellationAsync<T, T>ITransformWithProgressAsync<T, T, Report>ITransformAsync<T, T>
- Inherited Members
-
TransformerBase<T, T, Report>.CreateProgressReport()TransformerBase<T, T, Report>.IncrementCurrentItemCount()TransformerBase<T, T, Report>.IncrementCurrentSkippedItemCount()TransformerBase<T, T, Report>.ReportingIntervalTransformerBase<T, T, Report>.CurrentItemCountTransformerBase<T, T, Report>.CurrentSkippedItemCountTransformerBase<T, T, Report>.MaximumItemCountTransformerBase<T, T, Report>.SkipItemCount
Examples
var extractor = new TestExtractor<MyRecord>(items);
var transformer = new TestTransformer<MyRecord>();
var loader = new TestLoader<MyRecord>(collectItems: true);
await loader.LoadAsync(transformer.TransformAsync(extractor.ExtractAsync()));
Remarks
Useful when a pipeline requires a transformer in the chain but the test or benchmark is focused on the extractor or loader in isolation.
Methods
CreateProgressReport()
Creates a progress report object of type TProgress.
protected override Report CreateProgressReport()
Returns
- Report
TProgress - A new instance of the progress report object.
TransformWorkerAsync(IAsyncEnumerable<T>, CancellationToken)
The worker method that performs the actual transformation.
protected override IAsyncEnumerable<T> TransformWorkerAsync(IAsyncEnumerable<T> items, CancellationToken token)
Parameters
itemsIAsyncEnumerable<T>IAsyncEnumerable<TSource> - A list of 0 or more items to be transformed
tokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.