using Xunit; using ytLive.ViewModels; namespace ytLive.Tests; /// /// TRAX load-path guarding (2026-10-04). Startup used to freeze for ~40s when the /// music track lived on an offline network share: LoadLayout called /// MusicPlayer.Load synchronously, and new MediaFoundationReader(path) /// does not fail fast on a dead SMB session — it burns the full timeout and then /// throws 0x80070035. The fix is a bounded reachability probe on a background thread, /// so an unreachable share can never sit on the path the creator waits on. /// public class TraxProbeTests { /// The regression this guards: a probe that hangs must be abandoned at the /// budget and reported offline. Without the ceiling the caller inherits the SMB /// timeout, which is the 40-second frozen startup window. The orphaned probe thread /// is released at the end so the test does not leak it. [Fact] public async Task AHangingProbeIsAbandonedAtTheBudget_AndReportsOffline() { var orphan = new ManualResetEventSlim(false); var started = DateTime.UtcNow; try { var reachable = await MainViewModel.IsTrackReachableAsync( @"\\llamavault\llamaVault\Assets\Music\VBI - Mayhem OST.mp3", TimeSpan.FromMilliseconds(150), // Stands in for a share that has gone away: the open never completes. _ => { orphan.Wait(TimeSpan.FromSeconds(30)); return true; }); var elapsed = DateTime.UtcNow - started; Assert.False(reachable); Assert.True( elapsed < TimeSpan.FromSeconds(5), $"probe was not cut off at the budget — took {elapsed.TotalSeconds:0.0}s, which is the frozen-startup bug returning"); } finally { orphan.Set(); } } }