|
13 | 13 | using Microsoft.Agents.ObjectModel; |
14 | 14 | using Microsoft.Extensions.AI; |
15 | 15 | using Microsoft.Extensions.Configuration; |
| 16 | +using Microsoft.Extensions.Logging; |
16 | 17 | using Microsoft.PowerFx.Types; |
17 | 18 | using Moq; |
| 19 | +using Shared.UnitTests; |
18 | 20 | using Xunit.Sdk; |
19 | 21 |
|
20 | 22 | namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests; |
@@ -524,6 +526,36 @@ public void UnsupportedAction(Type type) |
524 | 526 | Assert.True(visitor.HasUnsupportedActions); |
525 | 527 | } |
526 | 528 |
|
| 529 | + [Fact] |
| 530 | + public void UnsupportedActionLogsWarning() |
| 531 | + { |
| 532 | + SearchKnowledgeSources.Builder unsupportedAction = new() { Id = "action_bad" }; |
| 533 | + AdaptiveDialog.Builder dialogBuilder = |
| 534 | + new() |
| 535 | + { |
| 536 | + BeginDialog = |
| 537 | + new OnActivity.Builder() |
| 538 | + { |
| 539 | + Id = "anything", |
| 540 | + Actions = [unsupportedAction] |
| 541 | + } |
| 542 | + }; |
| 543 | + AdaptiveDialog dialog = dialogBuilder.Build(); |
| 544 | + |
| 545 | + WorkflowFormulaState state = new(RecalcEngineFactory.Create()); |
| 546 | + Mock<ResponseAgentProvider> mockAgentProvider = CreateMockProvider("1"); |
| 547 | + CapturingLoggerFactory loggerFactory = new(); |
| 548 | + DeclarativeWorkflowOptions options = new(mockAgentProvider.Object) { LoggerFactory = loggerFactory }; |
| 549 | + WorkflowActionVisitor visitor = new(new DeclarativeWorkflowExecutor<string>(WorkflowActionVisitor.Steps.Root("anything"), options, state, (message) => DeclarativeWorkflowBuilder.DefaultTransform(message)), state, options); |
| 550 | + WorkflowElementWalker walker = new(visitor); |
| 551 | + walker.Visit(dialog); |
| 552 | + |
| 553 | + Assert.True(visitor.HasUnsupportedActions); |
| 554 | + (LogLevel Level, string Message) warning = Assert.Single(loggerFactory.Entries, entry => entry.Level == LogLevel.Warning); |
| 555 | + Assert.Contains(nameof(SearchKnowledgeSources), warning.Message, StringComparison.Ordinal); |
| 556 | + Assert.Contains("action_bad", warning.Message, StringComparison.Ordinal); |
| 557 | + } |
| 558 | + |
527 | 559 | [Theory] |
528 | 560 | [InlineData("CaseInsensitive.yaml", "end_when_match")] |
529 | 561 | [InlineData("ClearAllVariables.yaml", "clear_all")] |
|
0 commit comments