From 6a17cb867a36d11c24d06094e4b1799ce2be181f Mon Sep 17 00:00:00 2001 From: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com> Date: Thu, 11 Sep 2025 16:55:28 -0700 Subject: [PATCH] Fixed dotnet tests --- .../ActivityProcessor.cs | 26 +++++-------------- .../RunTests.cs | 3 +++ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/dotnet/src/Microsoft.Extensions.AI.Agents.CopilotStudio/ActivityProcessor.cs b/dotnet/src/Microsoft.Extensions.AI.Agents.CopilotStudio/ActivityProcessor.cs index e36c57ea78..f3c1db11a2 100644 --- a/dotnet/src/Microsoft.Extensions.AI.Agents.CopilotStudio/ActivityProcessor.cs +++ b/dotnet/src/Microsoft.Extensions.AI.Agents.CopilotStudio/ActivityProcessor.cs @@ -16,28 +16,16 @@ internal static class ActivityProcessor { await foreach (IActivity activity in activities.ConfigureAwait(false)) { - switch (activity.Type) + if (!string.IsNullOrWhiteSpace(activity.Text)) { - case "message": - // For streaming scenarios, we sometimes receive intermediate text via "typing" activities, but not always. - // In some cases the response is also returned multiple times via "typing" activities, so the only reliable - // way to get the final response is to wait for a "message" activity. - - // TODO: Prototype a custom AIContent type for CardActions, where the user is instructed to - // pick from a list of actions. - // The activity text doesn't make sense without the actions, as the message - // is often instructing the user to pick from the provided list of actions. + if ((activity.Type == "message" && !streaming) || (activity.Type == "typing" && streaming)) + { yield return CreateChatMessageFromActivity(activity, [new TextContent(activity.Text)]); - break; - case "typing": - case "event": - // TODO: Revisit usage of TextReasoningContent here, to evaluate whether all are really reasoning - // or whether simply an AIContent base type would be more appropriate. - yield return CreateChatMessageFromActivity(activity, [new TextReasoningContent(activity.Text)]); - break; - default: + } + else + { logger.LogWarning("Unknown activity type '{ActivityType}' received.", activity.Type); - break; + } } } } diff --git a/dotnet/tests/AgentConformance.IntegrationTests/RunTests.cs b/dotnet/tests/AgentConformance.IntegrationTests/RunTests.cs index 887faaac24..d2b34eb419 100644 --- a/dotnet/tests/AgentConformance.IntegrationTests/RunTests.cs +++ b/dotnet/tests/AgentConformance.IntegrationTests/RunTests.cs @@ -44,6 +44,7 @@ public abstract class RunTests(Func createAgentFix // Assert Assert.NotNull(response); + Assert.Single(response.Messages); Assert.Contains("Paris", response.Text); Assert.Equal(agent.Id, response.AgentId); } @@ -61,6 +62,7 @@ public abstract class RunTests(Func createAgentFix // Assert Assert.NotNull(response); + Assert.Single(response.Messages); Assert.Contains("Paris", response.Text); } @@ -82,6 +84,7 @@ public abstract class RunTests(Func createAgentFix // Assert Assert.NotNull(response); + Assert.Single(response.Messages); Assert.Contains("Paris", response.Text); }