using ClawdDotNet.Core.Scheduling; using Shouldly; namespace ClawdDotNet.Core.Tests.Scheduling; /// /// Time zones are named differently on Windows and Linux. Task files travel between /// the two — so each side must be able to interpret the other's spelling. /// /// The tests deliberately run on both platforms with the same expectations: exactly /// that is the property we need. /// public sealed class TimeZonesTests { [Theory] [InlineData("Europe/Berlin")] [InlineData("W. Europe Standard Time")] [InlineData("America/New_York")] [InlineData("Eastern Standard Time")] [InlineData("UTC")] public void Beide_Schreibweisen_sind_aufloesbar(string id) { TimeZones.TryResolve(id).ShouldNotBeNull(); TimeZones.IsKnown(id).ShouldBeTrue(); } [Fact] public void Beide_Schreibweisen_meinen_dieselbe_Zone() { var iana = TimeZones.TryResolve("Europe/Berlin"); var windows = TimeZones.TryResolve("W. Europe Standard Time"); var sommer = new DateTime(2026, 7, 31, 12, 0, 0, DateTimeKind.Utc); iana!.GetUtcOffset(sommer).ShouldBe(windows!.GetUtcOffset(sommer)); iana.GetUtcOffset(sommer).ShouldBe(TimeSpan.FromHours(2)); // CEST } [Theory] [InlineData("Phantasie/Ort")] [InlineData("Nicht Existierende Standard Time")] [InlineData("völliger Unsinn")] public void Unbekannte_Kennungen_werden_gemeldet_statt_geraten(string id) { TimeZones.TryResolve(id).ShouldBeNull(); TimeZones.IsKnown(id).ShouldBeFalse(); } [Fact] public void Leer_gilt_als_gueltig_denn_es_bedeutet_keine_Angabe() { TimeZones.IsKnown("").ShouldBeTrue(); TimeZones.IsKnown(null).ShouldBeTrue(); TimeZones.IsKnown(" ").ShouldBeTrue(); } [Theory] [InlineData("W. Europe Standard Time", "Europe/Berlin")] [InlineData("Europe/Berlin", "Europe/Berlin")] [InlineData("", "")] public void Normalisieren_ergibt_die_IANA_Schreibweise(string input, string expected) { TimeZones.ToIana(input).ShouldBe(expected); } [Fact] public void Eine_nicht_umsetzbare_Kennung_bleibt_unveraendert() { // Falsifying would be worse than passing through — that way, in case of doubt, // what originally stood there stays visible. TimeZones.ToIana("Phantasie Standard Time").ShouldBe("Phantasie Standard Time"); } [Fact] public void Die_lokale_Zone_wird_in_IANA_Schreibweise_geliefert() { var local = TimeZones.LocalIanaId; local.ShouldNotBeNullOrWhiteSpace(); TimeZones.IsKnown(local).ShouldBeTrue(); // The actual point: what comes out here is written into task files // and must be readable on the other platform. IANA identifiers contain a // slash, Windows identifiers never — UTC is the exception with neither. if (local != "UTC") local.ShouldContain("/"); } }