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); Assert.Contains("Value=\"{Binding TraxVolumeDb, Mode=TwoWay}\"", 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). var traxBay = dock[dock.IndexOf("Text=\"TRAX\"", System.StringComparison.Ordinal) ..dock.IndexOf("Text=\"LIP-SYNC\"", System.StringComparison.Ordinal)]; Assert.Contains("TraxTrackLabel", traxBay); Assert.Contains("SegmentMeter", traxBay); Assert.Contains("TraxMeterFraction", traxBay); foreach (var name in new[] { "TraxVolumeDb", "TraxVolumeDbLabel", "TraxTrackLabel", "IsTraxDucking", "TraxMeterFraction" }) 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")); // Unity means the bed's design level, and the fader's scale is the same one as the others. Assert.Equal(0, GainDb.ToDb(1f), 6); Assert.Contains("∞", GainDb.Label(GainDb.FloorDb)); // true silence, not "-60.0" } }