-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreAiChatPanelBuildRequestEditModeTests.cs
More file actions
80 lines (73 loc) · 2.79 KB
/
CoreAiChatPanelBuildRequestEditModeTests.cs
File metadata and controls
80 lines (73 loc) · 2.79 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
80
using CoreAI.Ai;
using CoreAI.Chat;
using NUnit.Framework;
using UnityEngine;
namespace CoreAI.Tests.EditMode
{
/// <summary>
/// Documents and guards that <see cref="CoreAiChatPanel"/> routing is driven by RoleId /
/// <see cref="BuildAiTaskRequest"/> — custom roles and tool policy injections are host concerns.
/// </summary>
[TestFixture]
public sealed class CoreAiChatPanelBuildRequestEditModeTests
{
private sealed class PanelForTesting : CoreAiChatPanel
{
public AiTaskRequest InvokeBuildAiTaskRequest(string userText, string roleId)
{
return BuildAiTaskRequest(userText, roleId);
}
}
private sealed class PanelWithAllowedTools : CoreAiChatPanel
{
protected override AiTaskRequest BuildAiTaskRequest(string userText, string roleId)
{
AiTaskRequest r = base.BuildAiTaskRequest(userText, roleId);
r.AllowedToolNames = new[] { "custom_tool_a" };
return r;
}
public AiTaskRequest InvokeBuildAiTaskRequest(string userText, string roleId)
{
return BuildAiTaskRequest(userText, roleId);
}
}
[Test]
public void BuildAiTaskRequest_Default_MapsHintRoleAndChatSourceTag()
{
GameObject go = new("ChatPanel_BuildRequest_Default");
try
{
PanelForTesting panel = go.AddComponent<PanelForTesting>();
AiTaskRequest req = panel.InvokeBuildAiTaskRequest(" hello ", "Merchant");
Assert.AreEqual("Merchant", req.RoleId);
Assert.AreEqual(" hello ", req.Hint);
Assert.AreEqual("Chat", req.SourceTag);
Assert.AreEqual(LlmToolChoiceMode.Auto, req.ForcedToolMode);
Assert.IsNull(req.AllowedToolNames);
}
finally
{
Object.DestroyImmediate(go);
}
}
[Test]
public void BuildAiTaskRequest_SubclassInjected_AllowedToolNames_Preserved()
{
GameObject go = new("ChatPanel_BuildRequest_Override");
try
{
PanelWithAllowedTools panel = go.AddComponent<PanelWithAllowedTools>();
AiTaskRequest req = panel.InvokeBuildAiTaskRequest("go", "BlueprintBot");
Assert.AreEqual("BlueprintBot", req.RoleId);
Assert.AreEqual("go", req.Hint);
Assert.IsNotNull(req.AllowedToolNames);
Assert.AreEqual(1, req.AllowedToolNames!.Length);
Assert.AreEqual("custom_tool_a", req.AllowedToolNames[0]);
}
finally
{
Object.DestroyImmediate(go);
}
}
}
}