champions-of-luneraria/Assets/Luneraria/Tests/Core/CheckSuite.cs
Martin Stickelbroeck 4d6ed17dca U1: Regelkern in C#, verhaltensgleich zur Godot-Referenz
Vollständiger, engineunabhängiger Regelkern (Luneraria.Core, ohne
UnityEngine): Partie mit sechs Plätzen und zwei Teams, private Planung mit
atomarer Übernahme, Gold, Käufe, Aufwertungen, Formation, drei Lanes mit
zwei Laneturmen und zwei Basistürmen je Team, Ancients, unbegrenzte Wellen,
Helden mit Stufen, Items und Talenten, Angriffschampions, Bossgrotte mit
Anspruch, Entsendung, Kopfgeld und dreirundiger Sperre, Bots und
Siegbedingung (nur Ancient-Fall). Serverautoritative Befehlsschnittstelle.

- Deterministisch: fester Takt, geordnete Maps, fortlaufende IDs, kein
  Zufall, keine Uhr, keine Threads
- Tabellen einmal aus Godot erzeugt (tools/port/gen_content.py)
- Golden-Referenzen aus Godot (tools/godot-golden): 19 Szenarien,
  120 Snapshots, 51.221 Werte, Abweichung 0 (Toleranzen dokumentiert)
- Tests: content 75, core 91, m2 73, golden 157, determinism 6 = 402/402
- Leistung (M5): Simulationsschritt 0,259 ms statt 1,587 ms in GDScript
- Referenzfehler R1 im Bot-Gedächtnis bewusst übernommen und dokumentiert
- Geplante Helden (Lucy, Ghaliga, Siegfried, Feena) im Datenmodell, inaktiv
- Doku unter docs/port (U1-RULES, PORT-STATUS, PORT-QA, U2 bis U5)

Unity-Editor-Lauf offen: Die Unity-Lizenz ist noch nicht aktiviert; gebaut
und getestet mit dem .NET 8 SDK auf Unitys Sprachstand (C# 9, .NET
Standard 2.1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 14:31:18 +02:00

56 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
namespace Luneraria.Core.Tests
{
/// <summary>
/// A test suite in the style of the Godot reference tests: named checks, counted, failures
/// collected with their label. The same suites run in the .NET harness (tools/dotnet) and in
/// Unity's Test Runner (Unity/CoreSuiteTests.cs); check counts stay comparable with Godot.
/// </summary>
public abstract class CheckSuite
{
public int Checks { get; private set; }
public readonly List<string> Failures = new List<string>();
public readonly List<string> Notes = new List<string>();
/// <summary>Folder with the golden files (Assets/Luneraria/Tests/Core/Golden).</summary>
public string GoldenDirectory = "";
public abstract string Name { get; }
protected abstract void RunChecks();
public bool Run()
{
Checks = 0;
Failures.Clear();
Notes.Clear();
try
{
RunChecks();
}
catch (Exception error)
{
Failures.Add("EXCEPTION " + error.GetType().Name + ": " + error.Message + "\n" + error.StackTrace);
}
return Failures.Count == 0;
}
protected void Check(bool ok, string label)
{
Checks += 1;
if (!ok)
Failures.Add(label);
}
protected void Note(string text)
{
Notes.Add(text);
}
public static IList<CheckSuite> All()
{
return new List<CheckSuite> { new ContentSuite(), new CoreRulesSuite(), new M2RulesSuite(), new GoldenSuite(), new DeterminismSuite() };
}
}
}