Files
agent-framework/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/DeclarativeCodeGenTest.cs
T
Stephen Toub a414461570 .NET: Re-enable ImplicitUsings in samples and clean up NoWarns (#1060)
* Re-enable ImplicitUsings in samples and clean up NoWarns

* Fix dotnet format

* More dotnet format

* More dotnet format

---------

Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
2025-10-01 19:37:03 +00:00

58 lines
2.9 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Framework;
using Xunit.Abstractions;
namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests;
/// <summary>
/// Tests execution of workflow created by <see cref="DeclarativeWorkflowBuilder"/>.
/// </summary>
[Collection("Global")]
public sealed class DeclarativeCodeGenTest(ITestOutputHelper output) : WorkflowTest(output)
{
[Theory]
[InlineData("SendActivity.yaml", "SendActivity.json", Skip = "Needs configuration")]
[InlineData("InvokeAgent.yaml", "InvokeAgent.json", Skip = "Needs configuration")]
[InlineData("ConversationMessages.yaml", "ConversationMessages.json", Skip = "Needs configuration")]
public Task ValidateCaseAsync(string workflowFileName, string testcaseFileName) =>
this.RunWorkflowAsync(Path.Combine("Workflows", workflowFileName), testcaseFileName);
[Theory]
[InlineData("Marketing.yaml", "Marketing.json", Skip = "Needs configuration")]
[InlineData("MathChat.yaml", "MathChat.json", Skip = "Needs configuration")]
[InlineData("DeepResearch.yaml", "DeepResearch.json", Skip = "Needs configuration")]
[InlineData("HumanInLoop.yaml", "HumanInLoop.json", Skip = "TODO")]
public Task ValidateScenarioAsync(string workflowFileName, string testcaseFileName) =>
this.RunWorkflowAsync(Path.Combine(GetRepoFolder(), "workflow-samples", workflowFileName), testcaseFileName);
protected override async Task RunAndVerifyAsync<TInput>(Testcase testcase, string workflowPath, DeclarativeWorkflowOptions workflowOptions)
{
const string WorkflowNamespace = "Test.WorkflowProviders";
const string WorkflowPrefix = "Test";
string workflowProviderCode = DeclarativeWorkflowBuilder.Eject(workflowPath, DeclarativeWorkflowLanguage.CSharp, WorkflowNamespace, WorkflowPrefix);
try
{
WorkflowEvents workflowEvents = await WorkflowHarness.RunCodeAsync(workflowProviderCode, $"{WorkflowPrefix}WorkflowProvider", WorkflowNamespace, workflowOptions, (TInput)GetInput<TInput>(testcase));
foreach (ExecutorEvent invokeEvent in workflowEvents.ExecutorInvokeEvents)
{
this.Output.WriteLine($"EXEC: {invokeEvent.ExecutorId}");
}
Assert.Empty(workflowEvents.ActionInvokeEvents);
Assert.Empty(workflowEvents.ActionCompleteEvents);
AssertWorkflow.EventCounts(workflowEvents.ExecutorInvokeEvents.Count - 2, testcase);
AssertWorkflow.EventCounts(workflowEvents.ExecutorCompleteEvents.Count - 2, testcase);
AssertWorkflow.EventSequence(workflowEvents.ExecutorInvokeEvents.Select(e => e.ExecutorId), testcase);
}
finally
{
this.Output.WriteLine($"CODE:\n{workflowProviderCode}");
}
}
}