< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Testing.PipelineScenarioRunner
Assembly: NexusLabs.Needlr.AgentFramework.Testing
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Testing/PipelineScenarioRunner.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 67
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%22100%
RunAsync()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Testing/PipelineScenarioRunner.cs

#LineLine coverage
 1using NexusLabs.Needlr.AgentFramework.Workflows.Sequential;
 2using NexusLabs.Needlr.AgentFramework.Workspace;
 3
 4namespace NexusLabs.Needlr.AgentFramework.Testing;
 5
 6/// <summary>
 7/// Runs <see cref="IPipelineScenario"/> instances using the
 8/// <see cref="SequentialPipelineRunner"/> and reports results.
 9/// </summary>
 10/// <remarks>
 11/// <para>
 12/// The runner handles the full seed → execute → verify lifecycle:
 13/// </para>
 14/// <list type="number">
 15///   <item>Creates an <see cref="InMemoryWorkspace"/> and calls <see cref="IPipelineScenario.SeedWorkspace"/>.</item>
 16///   <item>Builds the pipeline stages via <see cref="IPipelineScenario.BuildPipeline"/>.</item>
 17///   <item>Executes the pipeline using <see cref="SequentialPipelineRunner"/>.</item>
 18///   <item>Calls <see cref="IPipelineScenario.Verify"/> with the post-execution workspace and result.</item>
 19/// </list>
 20/// </remarks>
 21[DoNotAutoRegister]
 22public sealed class PipelineScenarioRunner
 23{
 24    private readonly SequentialPipelineRunner _pipelineRunner;
 25
 26    /// <summary>
 27    /// Initializes a new <see cref="PipelineScenarioRunner"/>.
 28    /// </summary>
 29    /// <param name="pipelineRunner">The sequential pipeline runner used to execute stages.</param>
 730    public PipelineScenarioRunner(SequentialPipelineRunner pipelineRunner)
 31    {
 732        _pipelineRunner = pipelineRunner ?? throw new ArgumentNullException(nameof(pipelineRunner));
 633    }
 34
 35    /// <summary>
 36    /// Runs the scenario with full lifecycle management: seed workspace,
 37    /// build pipeline, execute, and verify outcomes.
 38    /// </summary>
 39    /// <param name="scenario">The pipeline scenario to run.</param>
 40    /// <param name="services">Service provider for resolving pipeline dependencies.</param>
 41    /// <param name="cancellationToken">Cancellation token.</param>
 42    /// <returns>The result of the scenario run.</returns>
 43    public async Task<PipelineScenarioResult> RunAsync(
 44        IPipelineScenario scenario,
 45        IServiceProvider services,
 46        CancellationToken cancellationToken = default)
 47    {
 648        ArgumentNullException.ThrowIfNull(scenario);
 549        ArgumentNullException.ThrowIfNull(services);
 50
 451        var workspace = new InMemoryWorkspace();
 452        scenario.SeedWorkspace(workspace);
 53
 454        var stages = scenario.BuildPipeline(services);
 455        var options = scenario.GetOptions();
 56
 457        var result = await _pipelineRunner.RunAsync(
 458            workspace,
 459            stages,
 460            options,
 461            cancellationToken);
 62
 463        scenario.Verify(workspace, result);
 64
 465        return new PipelineScenarioResult(scenario.Name, workspace, result);
 466    }
 67}