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
@@ -13,7 +13,7 @@ namespace ClawdDotNet.App.Tests.Services;
|
||||
/// enabled the backup for one instance enabled it for all — and all
|
||||
/// archives lay in one folder in which retention cleans up by the prefix
|
||||
/// <c>backup_<Instanzname>_</c>. That a prefix is not a boundary is shown by
|
||||
/// <see cref="Im_gemeinsamen_Ordner_greift_die_Aufbewahrung_ueber_die_Instanz_hinaus"/>.</para>
|
||||
/// <see cref="In_the_shared_folder_retention_reaches_beyond_the_instance"/>.</para>
|
||||
/// </summary>
|
||||
public sealed class BackupSchedulerTests : IDisposable
|
||||
{
|
||||
@@ -27,7 +27,7 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>An instance directory with enough content that a backup is worthwhile.</summary>
|
||||
private string NeueInstanz(string name)
|
||||
private string NewInstance(string name)
|
||||
{
|
||||
var dir = Path.Combine(_root, "Instance-" + name);
|
||||
Directory.CreateDirectory(dir);
|
||||
@@ -50,25 +50,25 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
/// A clock standing at a time — the point in time decides whether
|
||||
/// <c>TickAsync</c> does anything.
|
||||
/// </summary>
|
||||
private sealed class FesteUhr(DateTime jetzt) : TimeProvider
|
||||
private sealed class FixedClock(DateTime jetzt) : TimeProvider
|
||||
{
|
||||
public override DateTimeOffset GetUtcNow() => new(jetzt, TimeSpan.Zero);
|
||||
public override TimeZoneInfo LocalTimeZone => TimeZoneInfo.Utc;
|
||||
}
|
||||
|
||||
private static BackupScheduler Scheduler(string dir, InstanceConfig config, DateTime jetzt)
|
||||
=> new(dir, config, NullLogger.Instance, new FesteUhr(jetzt));
|
||||
private static BackupScheduler Scheduler(string dir, InstanceConfig config, DateTime now)
|
||||
=> new(dir, config, NullLogger.Instance, new FixedClock(now));
|
||||
|
||||
private static DateTime Nachts(int tag) => new(2026, 9, tag, 4, 0, 0, DateTimeKind.Utc);
|
||||
private static DateTime AtNight(int tag) => new(2026, 9, tag, 4, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
// ─── The target folder ───
|
||||
|
||||
[Fact]
|
||||
public async Task Ohne_Angabe_landet_die_Sicherung_im_Instanzverzeichnis()
|
||||
public async Task Without_value_the_backup_ends_up_in_the_instance_directory()
|
||||
{
|
||||
var dir = NeueInstanz("Allein");
|
||||
var dir = NewInstance("Allein");
|
||||
|
||||
await Scheduler(dir, Config("Allein"), Nachts(1)).TickAsync();
|
||||
await Scheduler(dir, Config("Allein"), AtNight(1)).TickAsync();
|
||||
|
||||
var ziel = Path.Combine(dir, "Backups");
|
||||
Directory.Exists(ziel).ShouldBeTrue();
|
||||
@@ -76,13 +76,13 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Zwei_Instanzen_sichern_ohne_Angabe_getrennt()
|
||||
public async Task Two_instances_without_value_back_up_separately()
|
||||
{
|
||||
var a = NeueInstanz("Eins");
|
||||
var b = NeueInstanz("Zwei");
|
||||
var a = NewInstance("Eins");
|
||||
var b = NewInstance("Zwei");
|
||||
|
||||
await Scheduler(a, Config("Eins"), Nachts(1)).TickAsync();
|
||||
await Scheduler(b, Config("Zwei"), Nachts(1)).TickAsync();
|
||||
await Scheduler(a, Config("Eins"), AtNight(1)).TickAsync();
|
||||
await Scheduler(b, Config("Zwei"), AtNight(1)).TickAsync();
|
||||
|
||||
Directory.GetFiles(Path.Combine(a, "Backups"), "*.zip").Length.ShouldBe(1);
|
||||
Directory.GetFiles(Path.Combine(b, "Backups"), "*.zip").Length.ShouldBe(1);
|
||||
@@ -91,21 +91,21 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
// ─── The switch ───
|
||||
|
||||
[Fact]
|
||||
public async Task Ausgeschaltet_passiert_nichts()
|
||||
public async Task Switched_off_nothing_happens()
|
||||
{
|
||||
var dir = NeueInstanz("Ruhig");
|
||||
var dir = NewInstance("Ruhig");
|
||||
var config = Config("Ruhig");
|
||||
config.AutoBackupEnabled = false;
|
||||
|
||||
await Scheduler(dir, config, Nachts(1)).TickAsync();
|
||||
await Scheduler(dir, config, AtNight(1)).TickAsync();
|
||||
|
||||
Directory.Exists(Path.Combine(dir, "Backups")).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Vor_der_eingestellten_Uhrzeit_passiert_nichts()
|
||||
public async Task Before_the_configured_time_nothing_happens()
|
||||
{
|
||||
var dir = NeueInstanz("Frueh");
|
||||
var dir = NewInstance("Frueh");
|
||||
|
||||
await Scheduler(dir, Config("Frueh"), new DateTime(2026, 9, 1, 2, 0, 0, DateTimeKind.Utc))
|
||||
.TickAsync();
|
||||
@@ -114,10 +114,10 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Zweimal_am_selben_Tag_sichert_nur_einmal()
|
||||
public async Task Twice_on_the_same_day_backs_up_only_once()
|
||||
{
|
||||
var dir = NeueInstanz("Einmal");
|
||||
var scheduler = Scheduler(dir, Config("Einmal"), Nachts(1));
|
||||
var dir = NewInstance("Einmal");
|
||||
var scheduler = Scheduler(dir, Config("Einmal"), AtNight(1));
|
||||
|
||||
await scheduler.TickAsync();
|
||||
await scheduler.TickAsync();
|
||||
@@ -128,9 +128,9 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
// ─── Retention ───
|
||||
|
||||
[Fact]
|
||||
public async Task Die_Aufbewahrung_raeumt_die_eigenen_Archive_auf()
|
||||
public async Task Retention_cleans_up_its_own_archives()
|
||||
{
|
||||
var dir = NeueInstanz("Alt");
|
||||
var dir = NewInstance("Alt");
|
||||
var ziel = Path.Combine(dir, "Backups");
|
||||
Directory.CreateDirectory(ziel);
|
||||
|
||||
@@ -142,20 +142,20 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
File.SetLastWriteTime(datei, new DateTime(2026, 8, tag, 3, 0, 0));
|
||||
}
|
||||
|
||||
await Scheduler(dir, Config("Alt", keep: 2), Nachts(1)).TickAsync();
|
||||
await Scheduler(dir, Config("Alt", keep: 2), AtNight(1)).TickAsync();
|
||||
|
||||
Directory.GetFiles(ziel, "*.zip").Length.ShouldBe(2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Aufbewahrung_null_behaelt_alles()
|
||||
public async Task Retention_zero_keeps_everything()
|
||||
{
|
||||
var dir = NeueInstanz("Sammler");
|
||||
var dir = NewInstance("Sammler");
|
||||
var ziel = Path.Combine(dir, "Backups");
|
||||
Directory.CreateDirectory(ziel);
|
||||
File.WriteAllText(Path.Combine(ziel, "backup_Sammler_2026-08-01_0300.zip"), "alt");
|
||||
|
||||
await Scheduler(dir, Config("Sammler", keep: 0), Nachts(1)).TickAsync();
|
||||
await Scheduler(dir, Config("Sammler", keep: 0), AtNight(1)).TickAsync();
|
||||
|
||||
Directory.GetFiles(ziel, "*.zip").Length.ShouldBe(2);
|
||||
}
|
||||
@@ -171,31 +171,31 @@ public sealed class BackupSchedulerTests : IDisposable
|
||||
/// by entering the same folder for both instances.</para>
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task Im_gemeinsamen_Ordner_greift_die_Aufbewahrung_ueber_die_Instanz_hinaus()
|
||||
public async Task In_the_shared_folder_retention_reaches_beyond_the_instance()
|
||||
{
|
||||
var gemeinsam = Path.Combine(_root, "Backups");
|
||||
Directory.CreateDirectory(gemeinsam);
|
||||
var shared = Path.Combine(_root, "Backups");
|
||||
Directory.CreateDirectory(shared);
|
||||
|
||||
var fremd = Path.Combine(gemeinsam, "backup_Test_2_2026-08-01_0300.zip");
|
||||
File.WriteAllText(fremd, "gehoert Test_2");
|
||||
File.SetLastWriteTime(fremd, new DateTime(2026, 8, 1, 3, 0, 0));
|
||||
var foreign = Path.Combine(shared, "backup_Test_2_2026-08-01_0300.zip");
|
||||
File.WriteAllText(foreign, "gehoert Test_2");
|
||||
File.SetLastWriteTime(foreign, new DateTime(2026, 8, 1, 3, 0, 0));
|
||||
|
||||
var dir = NeueInstanz("Test");
|
||||
await Scheduler(dir, Config("Test", gemeinsam, keep: 1), Nachts(1)).TickAsync();
|
||||
var dir = NewInstance("Test");
|
||||
await Scheduler(dir, Config("Test", shared, keep: 1), AtNight(1)).TickAsync();
|
||||
|
||||
File.Exists(fremd).ShouldBeFalse(
|
||||
File.Exists(foreign).ShouldBeFalse(
|
||||
"Der alte Zustand ist damit belegt — im gemeinsamen Ordner räumt eine "
|
||||
+ "Instanz über ihre eigenen Archive hinaus auf.");
|
||||
|
||||
// And the counter-check: with separate folders they do not get in each other's way.
|
||||
var eigen = NeueInstanz("Test2");
|
||||
var eigenesArchiv = Path.Combine(eigen, "Backups", "backup_Test2_2026-08-01_0300.zip");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(eigenesArchiv)!);
|
||||
File.WriteAllText(eigenesArchiv, "gehoert Test2");
|
||||
var own = NewInstance("Test2");
|
||||
var ownArchive = Path.Combine(own, "Backups", "backup_Test2_2026-08-01_0300.zip");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(ownArchive)!);
|
||||
File.WriteAllText(ownArchive, "gehoert Test2");
|
||||
|
||||
var dir2 = NeueInstanz("Test3");
|
||||
await Scheduler(dir2, Config("Test3", keep: 1), Nachts(2)).TickAsync();
|
||||
var dir2 = NewInstance("Test3");
|
||||
await Scheduler(dir2, Config("Test3", keep: 1), AtNight(2)).TickAsync();
|
||||
|
||||
File.Exists(eigenesArchiv).ShouldBeTrue();
|
||||
File.Exists(ownArchive).ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user