mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
test: Add tests for failure when .AsAgent used on a non-ChatProtocol workflow
This commit is contained in:
@@ -206,6 +206,14 @@ internal sealed class TurnTrackingStartExecutor : ChatProtocolExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public class NonChatProtocolExecutor() : Executor<string>(nameof(NonChatProtocolExecutor))
|
||||
{
|
||||
public override ValueTask HandleAsync(string message, IWorkflowContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public class WorkflowHostSmokeTests : AIAgentHostingExecutorTestsBase
|
||||
{
|
||||
private sealed class AlwaysFailsAIAgent(bool failByThrowing) : AIAgent
|
||||
@@ -732,6 +740,25 @@ public class WorkflowHostSmokeTests : AIAgentHostingExecutorTestsBase
|
||||
.BeEmpty();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task Test_AsAgent_FailsWhenNotChatProtocolAsync(bool runAsync)
|
||||
{
|
||||
// Arrange
|
||||
NonChatProtocolExecutor executor = new();
|
||||
executor.DescribeProtocol().IsChatProtocol().Should().BeFalse();
|
||||
|
||||
Workflow workflow = new WorkflowBuilder(executor).Build();
|
||||
AIAgent workflowAsAgent = workflow.AsAIAgent();
|
||||
|
||||
Func<Task> action = runAsync
|
||||
? () => workflowAsAgent.RunStreamingAsync().ToAgentResponseAsync()
|
||||
: () => workflowAsAgent.RunAsync();
|
||||
|
||||
await action.Should().ThrowAsync<InvalidOperationException>();
|
||||
}
|
||||
|
||||
private async Task Run_AsAgent_OutgoingMessagesInHistoryAsync(Workflow workflow, bool runAsync)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user