Skip to content

.NET: test: add AgentResponse coverage for protected constructor, message property propagation, and [JsonIgnore] fields#6232

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

.NET: test: add AgentResponse coverage for protected constructor, message property propagation, and [JsonIgnore] fields#6232
challaravinath wants to merge 1 commit into
microsoft:mainfrom
challaravinath:challaravinath-agentresponse-coverage

Conversation

@challaravinath
Copy link
Copy Markdown
Contributor

Motivation and Context

AgentResponse had no tests covering the protected copy constructor (null guard or property copying), ToAgentResponseUpdates message-level field propagation (AuthorName, AdditionalProperties), or [JsonIgnore] exclusion of Text and RawRepresentation from serialized output. These are gaps in critical response construction and serialization paths.

Description

  • Add test verifying null AgentResponse passed to protected copy constructor throws ArgumentNullException
  • Add test verifying protected copy constructor copies all properties and sets RawRepresentation to the original instance
  • Add test verifying ToAgentResponseUpdates propagates message-level AuthorName to the update
  • Add test verifying ToAgentResponseUpdates propagates message-level AdditionalProperties to the update
  • Add test verifying Text and RawRepresentation are excluded from JSON serialization output

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
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.
  • No breaking change test only, no production code modified

…ssage property propagation, and [JsonIgnore] fields
Copilot AI review requested due to automatic review settings June 1, 2026 08:38
@moonbox3 moonbox3 added the .NET label Jun 1, 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

Note

Copilot was unable to run its full agentic suite in this review.

Adds additional unit tests around AgentResponse copying behavior, update propagation, and JSON serialization exclusions.

Changes:

  • Added tests for AgentResponse protected copy-constructor (null argument + property copy behavior).
  • Added tests validating ToAgentResponseUpdates() propagates author name and message additional properties.
  • Added a test ensuring JSON serialization excludes Text and RawRepresentation.

Comment on lines +368 to +371
AgentResponseUpdate[] updates = response.ToAgentResponseUpdates();

// Assert
Assert.Equal("bot", updates[0].AuthorName);
Comment on lines +382 to +385
AgentResponseUpdate[] updates = response.ToAgentResponseUpdates();

// Assert
Assert.Same(messageProps, updates[0].AdditionalProperties);
Comment on lines +351 to +358
Assert.Same(original.AdditionalProperties, copy.AdditionalProperties);
Assert.Equal(original.CreatedAt, copy.CreatedAt);
Assert.Equal(original.FinishReason, copy.FinishReason);
Assert.Same(original.Messages, copy.Messages);
Assert.Same(original, copy.RawRepresentation);
Assert.Equal(original.ResponseId, copy.ResponseId);
Assert.Same(original.Usage, copy.Usage);
Assert.Equivalent(original.ContinuationToken, copy.ContinuationToken);
Comment on lines +401 to +406
using JsonDocument doc = JsonDocument.Parse(json);
foreach (JsonProperty prop in doc.RootElement.EnumerateObject())
{
Assert.NotEqual("text", prop.Name, StringComparer.OrdinalIgnoreCase);
Assert.NotEqual("rawRepresentation", prop.Name, StringComparer.OrdinalIgnoreCase);
}
@github-actions github-actions Bot changed the title .NET: test: add AgentResponse coverage for protected constructor, message property propagation, and [JsonIgnore] fields .NET: .NET: test: add AgentResponse coverage for protected constructor, message property propagation, and [JsonIgnore] fields Jun 1, 2026
@challaravinath challaravinath changed the title .NET: .NET: test: add AgentResponse coverage for protected constructor, message property propagation, and [JsonIgnore] fields .NET: test: add AgentResponse coverage for protected constructor, message property propagation, and [JsonIgnore] fields Jun 1, 2026
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