using System; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using Xunit; using ytLive.Helpers; namespace ytLive.Tests; /// /// Build attribution (2026-09-04): the UI carries the release counter (#N, +1 per /// commit, from git rev-list — stable across rebuilds of one commit); the per-build /// GUID stays in startup.log for forensics. /// every build stamps a fresh GUID (ytLive.csproj GenerateBuildStamp), shown as the /// wordmark superscript and logged at startup. The unit pins the stamp shape; the /// RealApp test proves the wordmark ACTUALLY displays it (XAML wiring, live visual /// tree) — a stamp nobody can see would not have ended the guessing. /// public sealed class BuildStampTests { [Fact] public void Stamp_IsAFreshHexIdAndParsableTimestamp() { // The UI shows the RELEASE COUNTER (creator ruling 2026-09-04: a per-build // GUID changed on every launch and read as noise; #N ticks +1 per commit, // started at 13 — derived from git rev-list, stable within a commit). Assert.True(BuildStamp.Release >= 13, $"release counter regressed: {BuildStamp.Release}"); Assert.Equal(BuildStamp.Label, $"#{BuildStamp.Release}"); // The GUID survives as the forensic per-build id (startup.log only). Assert.Matches(new Regex("^[0-9a-f]{8}$"), BuildStamp.Id); Assert.True(DateTime.TryParseExact(BuildStamp.BuiltLocal, "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out var built)); Assert.True(built <= DateTime.Now); Assert.True(built.Date >= new DateTime(2026, 9, 4)); } } [Collection("RealApp")] public sealed class BuildStampDisplayTests { private readonly RealAppHost _app; public BuildStampDisplayTests(RealAppHost app) => _app = app; [Fact] public void Wordmark_Shows_The_Build_Stamp_As_Superscript() { _app.Run(() => { var window = new MainWindow(); try { // TopBar is its own namescope (UserControl) — FindName from the // control, never from the window (MyMistakes: namescoped FindName). var topBar = (UserControl)window.FindName("TopBar")!; var stamp = (Run)topBar.FindName("BuildIdStamp")!; Assert.Equal(BuildStamp.Label, stamp.Text); Assert.Equal(BaselineAlignment.Superscript, stamp.BaselineAlignment); } finally { window.Close(); } }); } }