Add repeated chain executor coverage

Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/af831ee2-0a99-4427-9ffd-a3b5022c1b3b

Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-13 19:16:28 +00:00
committed by GitHub
Unverified
parent 9a02dafbc3
commit 5ce002d3fd
2 changed files with 12 additions and 3 deletions
@@ -128,9 +128,16 @@ public static class WorkflowBuilderExtensions
Throw.IfNull(targets);
List<ExecutorBinding> targetList = [];
int targetIndex = 0;
foreach (ExecutorBinding? target in targets)
using IEnumerator<ExecutorBinding> targetEnumerator = targets.GetEnumerator();
if (!targetEnumerator.MoveNext())
{
throw new ArgumentException("Targets collection cannot be empty.", nameof(targets));
}
int targetIndex = 0;
do
{
ExecutorBinding? target = targetEnumerator.Current;
if (target is null)
{
throw new ArgumentNullException(nameof(targets), $"Targets collection contains a null element at index {targetIndex}.");
@@ -139,8 +146,8 @@ public static class WorkflowBuilderExtensions
targetList.Add(target);
targetIndex++;
}
while (targetEnumerator.MoveNext());
Throw.IfNullOrEmpty(targetList, nameof(targets));
return targetList;
}
@@ -396,6 +396,7 @@ public partial class WorkflowBuilderSmokeTests
WorkflowBuilder builder = new("start");
NoOpExecutor source = new("start");
NoOpExecutor target = new("target");
NoOpExecutor otherTarget = new("other-target");
// Act/Assert
Assert.Throws<ArgumentNullException>("builder", () => ((WorkflowBuilder)null!).AddChain(source, [target]));
@@ -403,6 +404,7 @@ public partial class WorkflowBuilderSmokeTests
Assert.Throws<ArgumentNullException>("executors", () => builder.AddChain(source, null!));
Assert.Throws<ArgumentNullException>("executors", () => builder.AddChain(source, [target, null!]));
Assert.Throws<ArgumentException>("executors", () => builder.AddChain(source, [target, source]));
Assert.Throws<ArgumentException>("executors", () => builder.AddChain(source, [target, otherTarget, target]));
}
[Fact]