-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathMergeExcludedToolsTests.cs
More file actions
79 lines (64 loc) · 2.2 KB
/
MergeExcludedToolsTests.cs
File metadata and controls
79 lines (64 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
using Microsoft.Extensions.AI;
using System.ComponentModel;
using Xunit;
namespace GitHub.Copilot.SDK.Test;
public class MergeExcludedToolsTests
{
[Fact]
public void Tool_Names_Are_Added_To_ExcludedTools()
{
var tools = new List<AIFunction>
{
AIFunctionFactory.Create(Noop, "my_tool"),
};
var result = CopilotClient.MergeExcludedTools(null, tools);
Assert.NotNull(result);
Assert.Contains("my_tool", result!);
}
[Fact]
public void Merges_With_Existing_ExcludedTools_And_Deduplicates()
{
var existing = new List<string> { "view", "my_tool" };
var tools = new List<AIFunction>
{
AIFunctionFactory.Create(Noop, "my_tool"),
AIFunctionFactory.Create(Noop, "another_tool"),
};
var result = CopilotClient.MergeExcludedTools(existing, tools);
Assert.NotNull(result);
Assert.Equal(3, result!.Count);
Assert.Contains("view", result);
Assert.Contains("my_tool", result);
Assert.Contains("another_tool", result);
}
[Fact]
public void Returns_Null_When_No_Tools_Provided()
{
var result = CopilotClient.MergeExcludedTools(null, null);
Assert.Null(result);
}
[Fact]
public void Returns_ExcludedTools_Unchanged_When_Tools_Empty()
{
var existing = new List<string> { "view" };
var result = CopilotClient.MergeExcludedTools(existing, new List<AIFunction>());
Assert.Same(existing, result);
}
[Fact]
public void Returns_Tool_Names_When_ExcludedTools_Null()
{
var tools = new List<AIFunction>
{
AIFunctionFactory.Create(Noop, "my_tool"),
};
var result = CopilotClient.MergeExcludedTools(null, tools);
Assert.NotNull(result);
Assert.Single(result!);
Assert.Equal("my_tool", result[0]);
}
[Description("No-op")]
static string Noop() => "";
}