Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Created unit test project covering all extension methods in AgentsClientExtensions.cs for the Microsoft.Agents.AI.AzureAIAgents package.

Test Project Structure

  • Location: dotnet/tests/Microsoft.Agents.AI.AzureAIAgents.UnitTests/
  • Follows conventions from existing test projects (Microsoft.Agents.AI.AzureAI.UnitTests, Microsoft.Agents.AI.OpenAI.UnitTests)
  • Standard dependencies: xUnit, Moq, project reference to source

Test Coverage (30+ tests)

  • GetAIAgent variants: AgentRecord/AgentVersion/name-based retrieval, options override, clientFactory injection
  • GetAIAgentAsync variants: Async name-based retrieval with options
  • CreateAIAgent variants: Basic parameters, AgentDefinition, ChatClientAgentOptions
  • CreateAIAgentAsync variants: Async creation with AgentDefinition
  • Validation tests: Null/empty/whitespace checks, agent-not-found scenarios, model requirement enforcement

Implementation Notes

Tests use Moq to mock AgentsClient and related types, testing extension method logic without service calls. Helper methods create test fixtures for AgentRecord, AgentVersion, and AgentDefinition.

Build Requirement

Requires Azure.AI.Agents (v2.0.0-alpha.20251024.3) from Azure DevOps private feed. Tests compile and run in CI/CD with proper Azure Artifacts authentication. See project README for setup details.

// Example test pattern
[Fact]
public void GetAIAgent_WithAgentRecord_CreatesValidAgent()
{
    // Arrange
    AgentsClient client = this.CreateTestAgentsClient();
    AgentRecord agentRecord = this.CreateTestAgentRecord();

    // Act
    var agent = client.GetAIAgent("test-model", agentRecord);

    // Assert
    Assert.NotNull(agent);
    Assert.Equal("test-agent", agent.Name);
}
Original prompt

Create a comprehensive unit test project for the Microsoft.Agents.AI.AzureAIAgents package that covers all extension method scenarios in the AgentsClientExtensions.cs file.

Requirements:

  1. Project Setup:

    • Create a new test project named Microsoft.Agents.AI.AzureAIAgents.UnitTests in the dotnet/test directory
    • Follow the same project structure, naming conventions, and organization patterns as existing test projects in the dotnet/test folder
    • Include all necessary dependencies (testing frameworks, mocking libraries, etc.) consistent with other test projects in the repository
  2. Test Implementation:

    • Write unit tests covering all extension methods defined in dotnet/src/Microsoft.Agents.AI.AzureAIAgents/AgentsClientExtensions.cs
    • Follow the same testing patterns, conventions, and style used in existing test projects
    • Test only through the public API surface - do NOT use reflection or access internal components
    • Ensure tests cover various scenarios for each extension method (success cases, edge cases, error conditions, parameter validation, etc.)
  3. Test Execution:

    • Ensure tests can be run using PowerShell commands with dotnet test --filter "FullyQualifiedName~" syntax
    • Follow .editorconfig rules and coding standards (no trailing whitespaces, braces for all ifs, this. prefix for non-static members, netstandard2.0 compatibility where applicable)
    • Use lower cyclomatic complexity patterns (early returns, minimal nesting, avoid unnecessary else blocks)

Before creating the test project, examine existing test projects in dotnet/test to understand the established patterns for project structure, dependencies, test organization, and naming conventions.


✨ 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 changed the title [WIP] Create comprehensive unit test project for AzureAIAgents package Add comprehensive unit tests for Microsoft.Agents.AI.AzureAIAgents extension methods Oct 29, 2025
Copilot AI requested a review from rogerbarreto October 29, 2025 18:19
Copilot finished work on behalf of rogerbarreto October 29, 2025 18:19
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Oct 30, 2025
@github-actions github-actions bot changed the title Add comprehensive unit tests for Microsoft.Agents.AI.AzureAIAgents extension methods .NET: Add comprehensive unit tests for Microsoft.Agents.AI.AzureAIAgents extension methods Oct 30, 2025
@rogerbarreto rogerbarreto marked this pull request as ready for review October 30, 2025 11:20
Copilot AI review requested due to automatic review settings October 30, 2025 11:20
Copy link
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

This PR adds unit test coverage for the AgentsClientExtensions class and fixes a bug in the GetAIAgent methods where the .Value property was missing when accessing ClientResult objects. Additionally, it updates the Azure.AI.Agents.Persistent package version from 1.2.0-beta.6 to 1.2.0-beta.7.

  • Adds comprehensive unit tests for all AgentsClientExtensions methods
  • Fixes bug where .Value property was not accessed on ClientResult return values
  • Updates Azure.AI.Agents.Persistent package version

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet/tests/Microsoft.Agents.AI.AzureAIAgents.UnitTests/Microsoft.Agents.AI.AzureAIAgents.UnitTests.csproj Creates new test project for AzureAIAgents unit tests
dotnet/tests/Microsoft.Agents.AI.AzureAIAgents.UnitTests/AgentsClientExtensionsTests.cs Adds comprehensive unit tests covering all extension methods with parameter validation and functionality tests
dotnet/src/Microsoft.Agents.AI.AzureAIAgents/AgentsClientExtensions.cs Fixes bug by adding .Value to access the actual value from ClientResult objects in GetAIAgent methods
dotnet/agent-framework-dotnet.slnx Adds the new test project to the solution
dotnet/Directory.Packages.props Updates Azure.AI.Agents.Persistent package version

@rogerbarreto rogerbarreto merged commit b31086d into feature-foundry-agents Oct 30, 2025
3 checks passed
@crickman crickman deleted the copilot/add-unit-tests-for-agentsclientextensions branch October 30, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants