mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
af772997af
* Migrate .NET GitHub Copilot SDK from 1.0.0-beta.2 to 1.0.0 - Update namespace from GitHub.Copilot.SDK to GitHub.Copilot - Replace PermissionRequestResult/PermissionRequestResultKind with PermissionDecision - Remove ConnectionState check (StartAsync is now idempotent) - Rename ConfigDir to ConfigDirectory - Use SessionConfig.Clone() for CopySessionConfig - Update Tools type from List<AIFunction> to List<AIFunctionDeclaration> - Rename UserMessageAttachmentFile to AttachmentFile - Update usage data types (CacheWriteTokens: long, Duration: TimeSpan) - Add GHCP001 NoWarn for experimental SDK APIs (matches framework convention) - Specify type argument on CopilotSession.On<SessionEvent>() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix formatting: remove unused using directive Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Skip AzureFunctions SamplesValidation tests pending func tools fix Azure Functions Core Tools v4 can no longer auto-detect the worker runtime in CI (local.settings.json is gitignored). All 7 active SamplesValidation tests fail with 'Worker runtime cannot be None'. Tracked by: https://github.com/microsoft/agent-framework/issues/6402 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Skip additional failing integration tests in CI WorkflowSamplesValidation (5 tests): same func tools issue as #6402. WorkflowConsoleAppSamplesValidation (4 tests): KeyNotFoundException during workflow execution, tracked by #6404. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using GitHub.Copilot;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace Microsoft.Agents.AI.GitHub.Copilot.UnitTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for the <see cref="CopilotClientExtensions"/> class.
|
|
/// </summary>
|
|
public sealed class CopilotClientExtensionsTests
|
|
{
|
|
[Fact]
|
|
public void AsAIAgent_WithAllParameters_ReturnsGitHubCopilotAgentWithSpecifiedProperties()
|
|
{
|
|
// Arrange
|
|
CopilotClient copilotClient = new(new CopilotClientOptions());
|
|
|
|
const string TestId = "test-agent-id";
|
|
const string TestName = "Test Agent";
|
|
const string TestDescription = "This is a test agent description";
|
|
|
|
// Act
|
|
var agent = copilotClient.AsAIAgent(ownsClient: false, id: TestId, name: TestName, description: TestDescription, tools: null);
|
|
|
|
// Assert
|
|
Assert.NotNull(agent);
|
|
Assert.IsType<GitHubCopilotAgent>(agent);
|
|
Assert.Equal(TestId, agent.Id);
|
|
Assert.Equal(TestName, agent.Name);
|
|
Assert.Equal(TestDescription, agent.Description);
|
|
}
|
|
|
|
[Fact]
|
|
public void AsAIAgent_WithMinimalParameters_ReturnsGitHubCopilotAgent()
|
|
{
|
|
// Arrange
|
|
CopilotClient copilotClient = new(new CopilotClientOptions());
|
|
|
|
// Act
|
|
var agent = copilotClient.AsAIAgent(ownsClient: false, tools: null);
|
|
|
|
// Assert
|
|
Assert.NotNull(agent);
|
|
Assert.IsType<GitHubCopilotAgent>(agent);
|
|
}
|
|
|
|
[Fact]
|
|
public void AsAIAgent_WithNullClient_ThrowsArgumentNullException()
|
|
{
|
|
// Arrange
|
|
CopilotClient? copilotClient = null;
|
|
|
|
// Act & Assert
|
|
Assert.Throws<ArgumentNullException>(() => copilotClient!.AsAIAgent(sessionConfig: null));
|
|
}
|
|
|
|
[Fact]
|
|
public void AsAIAgent_WithOwnsClient_ReturnsAgentThatOwnsClient()
|
|
{
|
|
// Arrange
|
|
CopilotClient copilotClient = new(new CopilotClientOptions());
|
|
|
|
// Act
|
|
var agent = copilotClient.AsAIAgent(ownsClient: true, tools: null);
|
|
|
|
// Assert
|
|
Assert.NotNull(agent);
|
|
Assert.IsType<GitHubCopilotAgent>(agent);
|
|
}
|
|
|
|
[Fact]
|
|
public void AsAIAgent_WithTools_ReturnsAgentWithTools()
|
|
{
|
|
// Arrange
|
|
CopilotClient copilotClient = new(new CopilotClientOptions());
|
|
List<AITool> tools = [AIFunctionFactory.Create(() => "test", "TestFunc", "Test function")];
|
|
|
|
// Act
|
|
var agent = copilotClient.AsAIAgent(tools: tools);
|
|
|
|
// Assert
|
|
Assert.NotNull(agent);
|
|
Assert.IsType<GitHubCopilotAgent>(agent);
|
|
}
|
|
}
|