mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
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:
committed by
GitHub
Unverified
parent
9a02dafbc3
commit
5ce002d3fd
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user