Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Motivation and Context

Unit test coverage for Microsoft.Agents.AI.AzureAI was at 64.5%, below the required 85% threshold.

Description

Added 30 new unit tests in AzureAIProjectChatClientExtensionsCoverageTests targeting uncovered code paths:

  • Name validation: Empty/null/whitespace agent name handling in GetAIAgentAsync and CreateAIAgentAsync
  • Response formats: ChatResponseFormatText, ChatResponseFormatJson with/without schema, strict mode
  • RawRepresentationFactory: Null returns, CreateResponseOptions returns, non-matching types
  • Tool validation: Missing required tools, partial tool provision, wrong tool names
  • Options preservation: AIContextProviderFactory, ChatMessageStoreFactory, UseProvidedChatClientAsIs
  • Tool conversion: ResponseTool.AsAITool(), hosted tools, mixed server tools

Also fixed net472 build compatibility by replacing ValueTask.CompletedTask with default.

Coverage results:

Component Before After
AzureAIProjectChatClientExtensions.cs 73.99% 90.08%
Overall Microsoft.Agents.AI.AzureAI ~64.5% 85.6%

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? No
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET: Improve unit test coverage for Microsoft.Agents.AI.AzureAI</issue_title>
<issue_description>Required level is 85%, current level is 64.5%

Image</issue_description>

<agent_instructions>Please analyze the Cobertura Coverage information related to the Microsoft.Agents.AI.AzureAI and lets improve its coverage on non-covered paths.

Please keep the same patterns used for UnitTests existing into the Microsoft.Agents.AI.AzureAI.UnitTests.

Use our repository guidelines regarding UnitTests code as well as use our existing File approach for the UnitTests generatino, only creating new ones if the file being covered have not being covered yet.

Ensure the coverage only covers non-covered paths without duplicating paths that are already covered.

Ensure all existing tests are working on top of the new added ones. This change should only be focused in UnitTests not changing any functionality.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 22, 2026 18:12
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve unit test coverage for Microsoft.Agents.AI.AzureAI .NET: Improve unit test coverage for Microsoft.Agents.AI.AzureAI to 85.6% Jan 22, 2026
Copilot AI requested a review from rogerbarreto January 22, 2026 18:19
@rogerbarreto
Copy link
Member

rogerbarreto commented Jan 23, 2026

@copilot

Address below with the project

Error: /home/runner/work/agent-framework/agent-framework/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs(3164,30): error CS0117: 'ValueTask' does not contain a definition for 'CompletedTask' [/home/runner/work/agent-framework/agent-framework/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/Microsoft.Agents.AI.AzureAI.UnitTests.csproj::TargetFramework=net472] (potentially using default may resolve)

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
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.

.NET: Improve unit test coverage for Microsoft.Agents.AI.AzureAI

3 participants