NPipeline.Extensions.Testing
0.15.0
See the version list below for details.
dotnet add package NPipeline.Extensions.Testing --version 0.15.0
NuGet\Install-Package NPipeline.Extensions.Testing -Version 0.15.0
<PackageReference Include="NPipeline.Extensions.Testing" Version="0.15.0" />
<PackageVersion Include="NPipeline.Extensions.Testing" Version="0.15.0" />
<PackageReference Include="NPipeline.Extensions.Testing" />
paket add NPipeline.Extensions.Testing --version 0.15.0
#r "nuget: NPipeline.Extensions.Testing, 0.15.0"
#:package NPipeline.Extensions.Testing@0.15.0
#addin nuget:?package=NPipeline.Extensions.Testing&version=0.15.0
#tool nuget:?package=NPipeline.Extensions.Testing&version=0.15.0
NPipeline Extensions Testing
NPipeline Extensions Testing is a comprehensive testing utilities package designed to help developers test their NPipeline pipelines effectively. This package provides in-memory test nodes, a test harness framework, assertion helpers, and pipeline testing utilities to simplify unit testing, integration testing, and performance testing of data processing pipelines.
About NPipeline
NPipeline is a high-performance, extensible data processing framework for .NET that enables developers to build scalable and efficient pipeline-based applications. It provides a rich set of components for data transformation, aggregation, branching, and parallel processing, with built-in support for resilience patterns and error handling.
Installation
dotnet add package NPipeline.Extensions.Testing
Requirements
- .NET 8.0, 9.0, or 10.0
- NPipeline core package
- xUnit, NUnit, or MSTest for test framework integration
Key Features
- In-Memory Test Nodes: Source and sink nodes that operate entirely in memory for fast, isolated testing
- Test Harness Framework: Fluent API for setting up and executing pipeline tests with assertion capabilities
- Assertion Helpers: Utilities to verify pipeline behavior, output, and performance characteristics
- Pipeline Testing Utilities: Specialized classes for running pipelines in test scenarios and capturing results
- Error Simulation: Components to simulate errors and test error handling behavior
- Performance Testing: Built-in timing and metrics collection for performance validation
Usage Examples
Basic Pipeline Testing
using NPipeline.Extensions.Testing;
using Xunit;
public class MyPipelineTests
{
[Fact]
public async Task MyPipeline_ShouldProcessDataCorrectly()
{
// Arrange
var testData = new List<string> { "item1", "item2", "item3" };
// Act
var result = await new PipelineTestHarness<MyProcessingPipeline>()
.WithParameter("inputData", testData)
.CaptureErrors()
.RunAsync();
// Assert
result.Success.Should().BeTrue();
result.Errors.Should().BeEmpty();
result.Duration.Should().BeLessThan(TimeSpan.FromSeconds(1));
}
}
In-Memory Node Usage
// Using InMemorySourceNode for test data
var sourceData = new List<int> { 1, 2, 3, 4, 5 };
var source = new InMemorySourceNode<int>(sourceData);
// Using InMemorySinkNode to capture results
var sink = new InMemorySinkNode<string>();
// Build pipeline with test nodes
var pipeline = PipelineBuilder
.Start.With(source)
.Then.Transform<int, string>(item => $"Processed: {item}")
.End.With(sink)
.Build();
// Execute pipeline
await PipelineRunner.Create().RunAsync(pipeline);
// Verify results
sink.Items.Should().HaveCount(5);
sink.Items.Should().Contain("Processed: 3");
Test Harness Setup
// Advanced test harness configuration
var result = await new PipelineTestHarness<ComplexPipeline>()
.WithParameter("batchSize", 100)
.WithParameter("timeout", TimeSpan.FromSeconds(30))
.WithContextItem("testMode", true)
.WithExecutionObserver(new TestExecutionObserver())
.CaptureErrors(PipelineErrorDecision.ContinueWithoutNode)
.RunAsync();
// Detailed assertions
result.Success.Should().BeTrue();
result.Context.Items["processedCount"].Should().Be(42);
result.Context.Metrics["totalDuration"].Should().BeLessThan(5000);
Assertion Examples
// Using PipelineExecutionResultExtensions for assertions
result.Should().Succeed();
result.Should().CompleteWithin(TimeSpan.FromSeconds(5));
result.Should().HaveNoErrors();
// Accessing captured errors for detailed validation
if (!result.Success)
{
result.Errors.Should().Contain(e => e.Message.Contains("expected error"));
result.Errors.Should().HaveCount(1);
}
// Verifying pipeline metrics
result.Context.Metrics.Should().ContainKey("itemsProcessed");
result.Context.Metrics["itemsProcessed"].Should().BeGreaterThan(0);
Testing Patterns
Unit Testing Pipelines
For unit testing individual pipeline components:
public class TransformNodeTests
{
[Fact]
public async Task CustomTransform_ShouldApplyLogicCorrectly()
{
// Arrange
var mockTransform = new MockNode<string, int>((input, context, token) =>
{
return Task.FromResult(input.Length);
});
var source = new InMemorySourceNode<string>(new[] { "short", "medium", "very long" });
var sink = new InMemorySinkNode<int>();
// Act
var pipeline = PipelineBuilder
.Start.With(source)
.Then.With(mockTransform)
.End.With(sink)
.Build();
await PipelineRunner.Create().RunAsync(pipeline);
// Assert
sink.Items.Should().BeEquivalentTo(new[] { 5, 6, 9 });
}
}
Integration Testing
For testing complete pipeline flows:
public class PipelineIntegrationTests
{
[Fact]
public async Task EndToEndPipeline_ShouldProcessRealWorldData()
{
// Arrange
var testData = LoadTestData();
var pipeline = new DataProcessingPipeline();
// Act
var result = await new PipelineTestHarness<DataProcessingPipeline>()
.WithParameter("dataSource", testData)
.CaptureErrors()
.RunAsync();
// Assert
result.Should().Succeed();
result.Context.GetSink<ProcessedDataSink>().Items.Should().HaveCount(testData.Count);
result.Context.Metrics["processingRate"].Should().BeGreaterThan(100); // items per second
}
}
Performance Testing
For validating performance characteristics:
public class PerformanceTests
{
[Fact]
public async Task Pipeline_ShouldHandleLargeVolumeEfficiently()
{
// Arrange
var largeDataSet = GenerateTestData(10000);
// Act
var result = await new PipelineTestHarness<HighVolumePipeline>()
.WithParameter("inputData", largeDataSet)
.RunAsync();
// Assert
result.Should().Succeed();
result.Duration.Should().BeLessThan(TimeSpan.FromSeconds(10));
result.Context.Metrics["throughput"].Should().BeGreaterThan(1000); // items per second
result.Context.Metrics["memoryUsage"].Should().BeLessThan(100 * 1024 * 1024); // 100MB
}
}
License
MIT License - see LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NPipeline.Extensions.Testing:
| Package | Downloads |
|---|---|
|
NPipeline.Extensions.Testing.AwesomeAssertions
AwesomeAssertions extensions for NPipeline testing - adds assertion methods for pipeline execution results |
|
|
NPipeline.Extensions.Testing.FluentAssertions
FluentAssertions extensions for NPipeline testing - adds fluent assertion methods for pipeline execution results |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.16.0 | 28 | 2/24/2026 |
| 0.15.0 | 58 | 2/19/2026 |
| 0.14.0 | 109 | 2/17/2026 |
| 0.13.1 | 117 | 2/13/2026 |
| 0.13.0 | 113 | 2/13/2026 |
| 0.12.0 | 124 | 2/9/2026 |
| 0.11.0 | 123 | 2/8/2026 |
| 0.10.0 | 125 | 2/6/2026 |
| 0.9.1 | 132 | 2/5/2026 |
| 0.9.0 | 122 | 2/5/2026 |
| 0.8.0 | 132 | 2/3/2026 |
| 0.7.1 | 135 | 2/1/2026 |
| 0.7.0 | 142 | 1/31/2026 |
| 0.6.6 | 127 | 1/21/2026 |
| 0.6.5 | 125 | 1/19/2026 |
| 0.6.4 | 124 | 1/18/2026 |
| 0.6.3 | 121 | 1/14/2026 |
| 0.6.2 | 131 | 1/13/2026 |
| 0.6.1 | 125 | 1/13/2026 |
| 0.6.0 | 130 | 1/13/2026 |