.NET: Improve unit test coverage for Microsoft.Agents.AI.Anthropic#3382
Merged
rogerbarreto merged 6 commits intomainfrom Jan 26, 2026
Merged
.NET: Improve unit test coverage for Microsoft.Agents.AI.Anthropic#3382rogerbarreto merged 6 commits intomainfrom
rogerbarreto merged 6 commits intomainfrom
Conversation
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve unit test coverage for Microsoft.Agents.AI.Anthropic
.NET: Improve unit test coverage for Microsoft.Agents.AI.Anthropic
Jan 22, 2026
…perty Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves unit test coverage for the Microsoft.Agents.AI.Anthropic project, increasing it from 68.7% to 100% line and branch coverage. The changes address uncovered code paths in the AsAIAgent extension methods for both AnthropicClientExtensions and AnthropicBetaServiceExtensions.
Changes:
- Added 12 new unit tests (6 per extension class) covering previously untested branches in the AsAIAgent methods
- Improved existing test assertions to verify agent state more thoroughly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Anthropic.UnitTests/Extensions/AnthropicClientExtensionsTests.cs | Added 6 new tests covering tools assignment, explicit max tokens, combined tools/instructions, empty tools, null instructions, and whitespace instructions scenarios. Added a CapturingHttpHandler helper class for testing HTTP requests. |
| dotnet/tests/Microsoft.Agents.AI.Anthropic.UnitTests/Extensions/AnthropicBetaServiceExtensionsTests.cs | Added identical 6 new tests for the Beta service extensions, covering the same scenarios as AnthropicClientExtensions. Added a CapturingHttpHandler helper class for testing HTTP requests. |
lokitoth
approved these changes
Jan 23, 2026
SergeyMenshykh
approved these changes
Jan 26, 2026
This was referenced Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Unit test coverage for
Microsoft.Agents.AI.Anthropicwas at 68.7%, below the 85% required threshold. BothAnthropicClientExtensionsandAnthropicBetaServiceExtensionshad uncovered branches inAsAIAgentmethods.Description
Added 12 new unit tests and improved assertions in existing tests to achieve 100% line and branch coverage for both extension classes.
New tests added (6 per extension class):
CreateAIAgent_WithTools_AssignsToolsCorrectlyCreateAIAgent_WithExplicitMaxTokens_UsesProvidedValueCreateAIAgent_WithToolsAndInstructions_AssignsBothCorrectlyCreateAIAgent_WithEmptyTools_DoesNotAssignToolsCreateAIAgent_WithNullInstructions_DoesNotSetInstructionsCreateAIAgent_WithWhitespaceInstructions_DoesNotSetInstructionsImproved test assertions:
Tests now verify actual agent state rather than just checking creation succeeded:
Contribution Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.