-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET Workflows - Add unit tests for ForeachExecutor (Declarative Workflows) #3835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds unit test coverage for the declarative workflows ForeachExecutor, and updates the workflow visitor wiring to use a new loop-completion method name (CompleteAsync) instead of ResetAsync.
Changes:
- Added
ForeachExecutorTest.cswith unit tests covering initialization, iteration, index handling, completion, and reset behavior. - Refactored
ForeachExecutorend-of-loop behavior by renamingResetAsync→CompleteAsyncand extracting shared state-reset logic. - Enhanced
WorkflowActionExecutorTesthelpers to support executing chained executors and selectively asserting discrete action events.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/WorkflowActionExecutorTest.cs | Adds helper overloads to execute single/multiple executors and optionally assert discrete action events. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs | New unit tests for ForeachExecutor execution paths and loop behaviors. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/CodeGen/ForeachTemplateTest.cs | Updates codegen test expectation from ResetAsync to CompleteAsync. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs | Renames loop completion method and factors out shared reset logic; adjusts initialization behavior. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowTemplateVisitor.cs | Updates generated workflow template naming to reference CompleteAsync. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs | Updates workflow graph wiring to invoke CompleteAsync at loop end. |
...tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/CodeGen/ForeachTemplateTest.cs
Show resolved
Hide resolved
...tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs
Outdated
Show resolved
Hide resolved
...tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs
Show resolved
Hide resolved
...tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs
Show resolved
Hide resolved
...tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs
Outdated
Show resolved
Hide resolved
...tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs
Show resolved
Hide resolved
…ts/ObjectModel/ForeachExecutorTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ts/ObjectModel/ForeachExecutorTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Motivation and Context
The
ForeachExecutorclass had no unit test coverage. Unit tests ensure correctness of loop initialization, value iteration logic, index tracking, and state reset behavior.Description
ForeachExecutorTest.cswith 100% line/branch coverageWorkflowActionExecutorTestto support non-discrete actionsDeclarativeWorkflowTestContribution Checklist