Files
ClawdDotNet/tests/ClawdDotNet.Core.Tests/Infrastructure/EngineFixture.cs
T
RichardandClaude Opus 5.5 837a634a22 Stufe 4c (#764): Kommentare in C#, WebUI-Skripten, CSS und HTML auf Englisch
Rund 2.600 Kommentarblöcke in 310 C#-Dateien übersetzt, Begründungen vollständig
erhalten: blockweise gleiche Anzahl wie vorher, kein Block unter 60 % seiner
Länge, der Code außerhalb der Kommentare per Tokenizer byte-identisch geprüft.
Zitate deutscher Oberflächentexte und Testdaten bleiben deutsch.

WebUI: Kommentare in JS/CSS/HTML übersetzt, JSDoc-@param an die in 4b
umbenannten Parameter angeglichen.

Dabei behoben:
- 4b hatte "tag" (HTML-Tag) als deutsches "Tag" gelesen und zu "dayValue"
  gemacht (makeElement, svg, Tagesübersicht) - zurück auf tag/day.
- Aufgaben "InProgress" bekamen die Plakettenart "laufend", für die es nie eine
  CSS-Klasse gab - jetzt "success" wie laufende Instanzen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:45:03 +02:00

81 lines
2.5 KiB
C#

using ClawdDotNet.Core.Accounting;
using ClawdDotNet.Core.Audit;
using ClawdDotNet.Core.Config;
using ClawdDotNet.Core.Engine;
using ClawdDotNet.Core.Security;
using ClawdDotNet.Core.Staging;
using ClawdDotNet.Core.Tools;
namespace ClawdDotNet.Core.Tests.Infrastructure;
/// <summary>
/// Assembles a ready-to-use AgentEngine with fake client, fake tools and
/// in-memory state.
/// </summary>
internal sealed class EngineFixture
{
public FakeChatClient Client { get; } = new();
public ToolRegistry Registry { get; } = new();
public InMemoryStateStore StateStore { get; } = new();
public AgentEngine Engine { get; }
private readonly List<AgentConfig> _agents = new();
/// <summary>The registered agents — for tests that build a dispatcher themselves.</summary>
public IReadOnlyList<AgentConfig> Agents => _agents;
public EngineFixture(
IAuditRepository? audit = null, StagingGate? staging = null, TimeProvider? clock = null,
IUsageRepository? usage = null, Core.Transcripts.IRunTranscriptStore? transcripts = null,
Core.Tasks.ITaskRepository? tasks = null)
{
Engine = new AgentEngine(
Client,
Registry,
new PermissionGate(),
StateStore,
TestLogging.Factory,
usageRepository: usage,
taskRepository: tasks,
auditRepository: audit,
stagingGate: staging,
clock: clock)
{
TranscriptStore = transcripts
};
// No agent directory → no persistence to disk during the tests.
Engine.SetAgentConfigProvider(() => _agents, "test-instance", _ => null);
}
public EngineFixture WithTool(IAgentTool tool)
{
Registry.Register(tool);
return this;
}
public AgentConfig AddAgent(string agentId, params string[] toolNames)
{
var config = new AgentConfig
{
AgentId = agentId,
DisplayName = agentId,
Model = "test/model",
SystemPrompt = $"Du bist {agentId}.",
LoopGuard = new LoopGuardConfig
{
MaxSteps = 50,
MaxCumulativeTokens = 10_000_000,
TimeoutSeconds = 60,
MaxContextTokens = 10_000_000 // switch off compaction in engine tests
}
};
foreach (var name in toolNames)
config.Tools[name] = new Dictionary<string, object?>();
_agents.Add(config);
return config;
}
}