Unit 7. The bay shows the track name (left-click toggles playback, right-click opens the picker — the label stays the control), a play/pause button, the duck badge, and a dB level. No ladder here, deliberately: nothing measures the music bed, and a decorative ladder would break the measured-not-painted rule. A test asserts the bay has no SegmentMeter. The level is real: `ITraxPlayer.UserGain` is a new creator gain multiplied onto the fixed design volume, separate from `LocalGain` (which follows the desktop mute). The VM's `TraxVolumeDb` is the same dB scale as the other faders, so unity means the bed's design level.
42 lines
2.0 KiB
C#
42 lines
2.0 KiB
C#
using Xunit;
|
|
using ytLive.Helpers;
|
|
using ytLive.Services.Audio;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>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.
|
|
/// </summary>
|
|
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);
|
|
|
|
// No ladder in the TRAX bay: nothing measures the bed, so there is nothing honest to show.
|
|
var traxBay = dock[dock.IndexOf("Text=\"TRAX\"", System.StringComparison.Ordinal)
|
|
..dock.IndexOf("Text=\"LIP-SYNC\"", System.StringComparison.Ordinal)];
|
|
Assert.Contains("TraxTrackLabel", traxBay);
|
|
Assert.DoesNotContain("SegmentMeter", traxBay);
|
|
|
|
foreach (var name in new[] { "TraxVolumeDb", "TraxVolumeDbLabel", "TraxTrackLabel", "IsTraxDucking" })
|
|
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(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"
|
|
}
|
|
}
|