Portierung der beiden fehlenden Grundbausteine aus PolytraderSharp (voller Ausbau). Core S-0 (Datenfundament fuer Analyse/Forensik): - core_decision_journal + core_order_events (+ ReasonCode/Decision/OrderEvent-Enums), IDecisionJournal/IOrderEventLog mit fehlertoleranten EF-Impls (Handel bricht nie). - SignalId-Durchreichung TradeSignal -> ExecutionService -> core_trade_history; ExecutionService schreibt an jeder Verzweigung Journal/Order-Events. - JSONL-Log-Sink (LogJson + Dual-Sink), pure Analytik: RealizedPnlEngine (FIFO), TradeAnalytics, DossierBuilder. Migration AddAnalysisFoundation. Accounting-Modul (acc_): unabhaengiger IBKR-Kontoauszug (Activity Flex Query) hinter Interfaces mit Offline-Null-Stubs -> append-only Ledger + Periodenabrechnung/BWA + FX (USD/EUR) + CSV/PDF (PDFsharp/MigraDoc). Steuerschicht bewusst offen (Platzhalter-Tab). Kein Handel. Migration InitialAccounting. Supervisor-Modul (sup_): read-only OpenRouter-Agent (Function-Calling-Loop) + read-only Tool-Registry (8 Tools) + Profile + Dossier-Browser + Counterfactual-Job (Stub) + Tagesbericht/MCP-Light (opt-in). Migration InitialSupervisor. Verdrahtung: Program.cs (beide Module + Icons), slnx/App/Tests-Referenzen, provision-db.ps1, AppSettings-Sektionen, docs/konzepte, README. Tests: 79 -> 117 gruen (FIFO/KPIs/Dossier/JSONL, Classifier/Engine/FX/Idempotenz, OpenRouter/Registry/Agent/MCP, STA-Konstruktion beider neuen Fenster). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using FluentAssertions;
|
|
using IBKRTrader.Modules.Supervisor.Agent;
|
|
|
|
namespace IBKRTrader.Tests.Modules.Supervisor;
|
|
|
|
[Trait("cat", "unit")]
|
|
public class SupervisorToolRegistryTests
|
|
{
|
|
private static SupervisorToolRegistry WithEcho()
|
|
{
|
|
var reg = new SupervisorToolRegistry();
|
|
reg.Register(new SupervisorTool("echo", "Echo", """{"type":"object","properties":{"x":{"type":"string"}}}""",
|
|
args => SupervisorToolRegistry.GetString(args, "x") ?? "(leer)"));
|
|
return reg;
|
|
}
|
|
|
|
[Fact]
|
|
public void UnknownTool_ReturnsErrorText_DoesNotThrow()
|
|
{
|
|
var reg = WithEcho();
|
|
reg.Execute("nope", "{}").Should().StartWith("FEHLER: Unbekanntes Tool");
|
|
}
|
|
|
|
[Fact]
|
|
public void InvalidJsonArgs_ReturnsErrorText()
|
|
{
|
|
var reg = WithEcho();
|
|
reg.Execute("echo", "{ kaputt").Should().StartWith("FEHLER: Ungültige Tool-Argumente");
|
|
}
|
|
|
|
[Fact]
|
|
public void ExecutesRegisteredTool()
|
|
{
|
|
var reg = WithEcho();
|
|
reg.Execute("echo", """{"x":"hallo"}""").Should().Be("hallo");
|
|
}
|
|
|
|
[Fact]
|
|
public void ToolException_IsCaught_AsErrorText()
|
|
{
|
|
var reg = new SupervisorToolRegistry();
|
|
reg.Register(new SupervisorTool("boom", "Boom", """{"type":"object"}""",
|
|
_ => throw new InvalidOperationException("geplatzt")));
|
|
|
|
reg.Execute("boom", "{}").Should().Contain("geplatzt");
|
|
}
|
|
}
|