using Xunit; using ytLive.Helpers; using ytLive.Services.Audio; using ytLive.ViewModels; namespace ytLive.Tests; /// The TRAX bay shows the track, plays/pauses it, and carries a level — but no meter: /// nothing measures the bed, and a decorative ladder would be a lie. Its fader moves a gain the /// player actually applies, separate from the desktop-mute follow. /// public class TraxBayTests { [Fact] public void The_trax_bay_binds_the_track_level_and_play_state_without_inventing_a_meter() { var dock = SourceAssert.Text("Controls", "AudioDock.xaml"); Assert.Contains("Text=\"{Binding TraxTrackLabel}\"", dock); // KISS (creator 2026-10-30): background music is one number and two ±5 dB buttons, not a // channel strip — and it has no ladder of its own, because the desktop bed already carries it. Assert.Contains("Click=\"TraxStepDown_Click\"", dock); Assert.Contains("Click=\"TraxStepUp_Click\"", dock); Assert.Contains("IsEnabled=\"{Binding CanLowerTrax}\"", dock); Assert.Contains("IsEnabled=\"{Binding CanRaiseTrax}\"", dock); Assert.Contains("Text=\"{Binding TraxVolumeDbLabel}\"", dock); Assert.Contains("Binding=\"{Binding IsMusicPlaying}\" Value=\"True\"", dock); Assert.Contains("Click=\"TraxPlayPause_Click\"", dock); // The bay DOES carry a ladder now — the player measures its own output, so "is music making // sound" is answerable without hearing it (a play glyph cannot answer that). // The TRAX row lives under the desktop volume, inside the GAME bay. var traxRow = dock[dock.IndexOf("Text=\"TRAX\"", System.StringComparison.Ordinal) ..dock.IndexOf("Text=\"LIP-SYNC\"", System.StringComparison.Ordinal)]; Assert.Contains("TraxTrackLabel", traxRow); Assert.DoesNotContain("SegmentMeter", traxRow); foreach (var name in new[] { "TraxVolumeDb", "TraxVolumeDbLabel", "TraxTrackLabel", "CanRaiseTrax", "CanLowerTrax" }) Assert.NotNull(typeof(MainViewModel).GetProperty(name)); // The player gained a real user level, separate from the mute-follow LocalGain. Assert.NotNull(typeof(ITraxPlayer).GetProperty("UserGain")); Assert.NotNull(typeof(ITraxPlayer).GetProperty("Level")); Assert.NotNull(typeof(MusicPlayer).GetProperty("UserGain")); // It starts as background: −50 dB, and the ±5 dB steps are how it moves. Assert.Equal(-50, MainViewModel.TraxDefaultDb); Assert.Equal(5, MainViewModel.TraxStepDb); Assert.Equal(0, GainDb.ToDb(1f), 6); Assert.Contains("∞", GainDb.Label(GainDb.FloorDb)); // true silence, not "-60.0" } }