Stufe 4c (#764): Bezeichner auf Englisch - Typen, Methoden, Felder, Parameter, Locals, Testnamen
Mit Roslyn umbenannt (Verweise folgen, Zeichenketten bleiben unberuehrt). Nicht umbenannt, weil gespeichert oder ueber die API gebunden (Stufe 4e): Properties, Record-Parameter, Enum-Member sowie die Parameter der Endpunkt-Handler (Routen-/Query-Bindung ueber den Namen). Die JSON-Felder anonymer Objekte bleiben ausdruecklich benannt (JsonFilter: pfad). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
837a634a22
commit
77062facc9
@@ -43,34 +43,34 @@ public sealed class SupervisionReporterTests
|
||||
{
|
||||
private readonly CapturingHandler _handler = new();
|
||||
|
||||
private SupervisionReporter Melder(Func<string, IReadOnlyList<string>>? auszug = null)
|
||||
private SupervisionReporter Reporter(Func<string, IReadOnlyList<string>>? excerpt = null)
|
||||
{
|
||||
var api = new DeploymentcenterApi("https://dc.example", "t", new HttpClient(_handler));
|
||||
var bugtracker = new BugtrackerClient(api, "clawddotnet", "production", "0.1.2");
|
||||
|
||||
return new SupervisionReporter(bugtracker, NullLogger.Instance, auszug ?? (_ => []));
|
||||
return new SupervisionReporter(bugtracker, NullLogger.Instance, excerpt ?? (_ => []));
|
||||
}
|
||||
|
||||
private static SupervisionEvent Ereignis(
|
||||
private static SupervisionEvent Event(
|
||||
InstanceEventKind kind, int? exitCode = null, string dir = @"C:\Instanzen\Instance-Alpha")
|
||||
=> new(kind, dir, "Alpha", 4711, exitCode, "Instanz Alpha ist unerwartet beendet worden.",
|
||||
DateTimeOffset.Parse("2026-09-08T17:27:45Z"));
|
||||
|
||||
[Fact]
|
||||
public async Task Ein_Absturz_geht_raus()
|
||||
public async Task A_crash_goes_out()
|
||||
{
|
||||
(await Melder().ReportAsync(Ereignis(InstanceEventKind.Crashed, exitCode: 137)))
|
||||
(await Reporter().ReportAsync(Event(InstanceEventKind.Crashed, exitCode: 137)))
|
||||
.ShouldBeTrue();
|
||||
|
||||
_handler.Calls.ShouldBe(1);
|
||||
|
||||
var rumpf = _handler.LastBody.ShouldNotBeNull();
|
||||
rumpf.ShouldContain("unerwartet beendet");
|
||||
rumpf.ShouldContain("4711");
|
||||
rumpf.ShouldContain("137");
|
||||
rumpf.ShouldContain("instanzmanager");
|
||||
rumpf.ShouldContain("clawddotnet"); // project binding
|
||||
rumpf.ShouldContain("0.1.2"); // build_version
|
||||
var body = _handler.LastBody.ShouldNotBeNull();
|
||||
body.ShouldContain("unerwartet beendet");
|
||||
body.ShouldContain("4711");
|
||||
body.ShouldContain("137");
|
||||
body.ShouldContain("instanzmanager");
|
||||
body.ShouldContain("clawddotnet"); // project binding
|
||||
body.ShouldContain("0.1.2"); // build_version
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -81,9 +81,9 @@ public sealed class SupervisionReporterTests
|
||||
[InlineData(InstanceEventKind.Started)]
|
||||
[InlineData(InstanceEventKind.StoppedOrderly)]
|
||||
[InlineData(InstanceEventKind.Recovered)]
|
||||
public async Task Alltag_wird_nicht_gemeldet(InstanceEventKind kind)
|
||||
public async Task Routine_is_not_reported(InstanceEventKind kind)
|
||||
{
|
||||
(await Melder().ReportAsync(Ereignis(kind))).ShouldBeFalse();
|
||||
(await Reporter().ReportAsync(Event(kind))).ShouldBeFalse();
|
||||
_handler.Calls.ShouldBe(0);
|
||||
}
|
||||
|
||||
@@ -93,31 +93,31 @@ public sealed class SupervisionReporterTests
|
||||
/// not a dozen identical ones.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task Dieselbe_Instanz_und_dieselbe_Art_ergeben_denselben_Schluessel()
|
||||
public async Task The_same_instance_and_kind_give_the_same_key()
|
||||
{
|
||||
var melder = Melder();
|
||||
var reporter = Reporter();
|
||||
|
||||
await melder.ReportAsync(Ereignis(InstanceEventKind.Crashed));
|
||||
var erster = SchluesselAus(_handler.LastBody!);
|
||||
await reporter.ReportAsync(Event(InstanceEventKind.Crashed));
|
||||
var firstOne = KeyFrom(_handler.LastBody!);
|
||||
|
||||
await melder.ReportAsync(Ereignis(InstanceEventKind.Crashed));
|
||||
SchluesselAus(_handler.LastBody!).ShouldBe(erster);
|
||||
await reporter.ReportAsync(Event(InstanceEventKind.Crashed));
|
||||
KeyFrom(_handler.LastBody!).ShouldBe(firstOne);
|
||||
|
||||
// A different kind is a different finding.
|
||||
await melder.ReportAsync(Ereignis(InstanceEventKind.Unresponsive));
|
||||
SchluesselAus(_handler.LastBody!).ShouldNotBe(erster);
|
||||
await reporter.ReportAsync(Event(InstanceEventKind.Unresponsive));
|
||||
KeyFrom(_handler.LastBody!).ShouldNotBe(firstOne);
|
||||
|
||||
// And a different instance all the more.
|
||||
await melder.ReportAsync(
|
||||
Ereignis(InstanceEventKind.Crashed, dir: @"C:\Instanzen\Instance-Beta"));
|
||||
SchluesselAus(_handler.LastBody!).ShouldNotBe(erster);
|
||||
await reporter.ReportAsync(
|
||||
Event(InstanceEventKind.Crashed, dir: @"C:\Instanzen\Instance-Beta"));
|
||||
KeyFrom(_handler.LastBody!).ShouldNotBe(firstOne);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Der_Protokollauszug_kommt_mit()
|
||||
public async Task The_log_excerpt_comes_along()
|
||||
{
|
||||
await Melder(_ => ["Startup.log: [17:26:50] [INF] Application is shutting down"])
|
||||
.ReportAsync(Ereignis(InstanceEventKind.Crashed));
|
||||
await Reporter(_ => ["Startup.log: [17:26:50] [INF] Application is shutting down"])
|
||||
.ReportAsync(Event(InstanceEventKind.Crashed));
|
||||
|
||||
_handler.LastBody.ShouldNotBeNull().ShouldContain("Application is shutting down");
|
||||
}
|
||||
@@ -128,9 +128,9 @@ public sealed class SupervisionReporterTests
|
||||
/// Exactly that was the state from #529.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task Ein_leerer_Protokollauszug_wird_ausdruecklich_gesagt()
|
||||
public async Task An_empty_log_excerpt_is_stated_explicitly()
|
||||
{
|
||||
await Melder(_ => []).ReportAsync(Ereignis(InstanceEventKind.Crashed));
|
||||
await Reporter(_ => []).ReportAsync(Event(InstanceEventKind.Crashed));
|
||||
|
||||
_handler.LastBody.ShouldNotBeNull().ShouldContain("KEINE");
|
||||
}
|
||||
@@ -141,20 +141,20 @@ public sealed class SupervisionReporterTests
|
||||
/// own report.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task Ein_Serverfehler_reisst_die_Aufsicht_nicht_mit()
|
||||
public async Task A_server_error_does_not_take_supervision_down()
|
||||
{
|
||||
var handler = new CapturingHandler(HttpStatusCode.InternalServerError,
|
||||
"""{"status":"error","error":{"code":"boom","message":"kaputt"}}""");
|
||||
|
||||
var api = new DeploymentcenterApi("https://dc.example", "t", new HttpClient(handler));
|
||||
var melder = new SupervisionReporter(
|
||||
var reporter = new SupervisionReporter(
|
||||
new BugtrackerClient(api, "clawddotnet", "production", "0.1.2"),
|
||||
NullLogger.Instance, _ => []);
|
||||
|
||||
(await melder.ReportAsync(Ereignis(InstanceEventKind.Crashed))).ShouldBeFalse();
|
||||
(await reporter.ReportAsync(Event(InstanceEventKind.Crashed))).ShouldBeFalse();
|
||||
}
|
||||
|
||||
private static string SchluesselAus(string body)
|
||||
private static string KeyFrom(string body)
|
||||
{
|
||||
using var doc = System.Text.Json.JsonDocument.Parse(body);
|
||||
return doc.RootElement.GetProperty("client_ref").GetString()!;
|
||||
|
||||
Reference in New Issue
Block a user