Skip to content

.NET: test: add AgentResponse edge case coverage#5841

Open
challaravinath wants to merge 1 commit into
microsoft:mainfrom
challaravinath:challaravinath-agentresponse-tests
Open

.NET: test: add AgentResponse edge case coverage#5841
challaravinath wants to merge 1 commit into
microsoft:mainfrom
challaravinath:challaravinath-agentresponse-tests

Conversation

@challaravinath
Copy link
Copy Markdown

Motivation and Context

AgentResponse had no tests covering null ChatResponse construction,
Text property behavior with non-text content, Text after Messages
is set to null, or message order preservation in ToAgentResponseUpdates.
These are gaps in critical response handling paths.
-->

Description

  • Add test verifying null ChatResponse constructor throws ArgumentNullException
  • Add test verifying Text returns empty string when all content is non-text
  • Add test verifying Text returns empty string after Messages is set to null
  • Add test verifying ToAgentResponseUpdates preserves message order across multiple messages

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • No breaking change test only, no production code modified

Copilot AI review requested due to automatic review settings May 14, 2026 07:36
@moonbox3 moonbox3 added the .NET label May 14, 2026
@github-actions github-actions Bot changed the title test: add AgentResponse edge case coverage .NET: test: add AgentResponse edge case coverage May 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 targeted unit tests in the .NET Abstractions test suite to cover previously untested AgentResponse edge cases, improving confidence in response handling behavior without modifying production code.

Changes:

  • Added a constructor guard test for AgentResponse(ChatResponse) when passed null.
  • Added Text behavior tests for non-text-only content and for Messages being set to null.
  • Added a test ensuring ToAgentResponseUpdates() preserves message ordering across multiple messages.

public void Constructor_WithNullChatResponse_ThrowsArgumentNullException()
{
// Act & Assert
Assert.Throws<ArgumentNullException>(() => new AgentResponse((ChatResponse)null!));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants