using System; using System.IO; using System.Linq; using Xunit; using ytLive.Models; using ytLive.ViewModels; namespace ytLive.Tests; /// /// The (+) menu's Blur entry is Live-scene only, and it is bound — so the view model has to /// re-notify `CanAddBlur` whenever the staged scene changes. It did not, and the option stayed /// collapsed for the rest of the session (build 1082: "it no longer appears as an option"). /// [Collection("MainViewModelLayoutPath")] public class BlurMenuAvailabilityTests { private static MainViewModel NewVm(out string dbPath) { dbPath = Path.Combine(Path.GetTempPath(), $"llamacasty-blurmenu-{Guid.NewGuid():N}.db"); MainViewModel.LayoutPathOverride = dbPath; return new MainViewModel(); } [Fact] public void Blur_is_offered_on_the_live_scene_only_and_the_flag_is_re_notified() { var vm = NewVm(out var dbPath); try { var live = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Live)); var chat = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Chat)); vm.StagedScene = live; Assert.True(vm.CanAddBlur, "the Live scene must offer the blur layer"); vm.StagedScene = chat; Assert.False(vm.CanAddBlur, "other scenes must not offer a desktop blur"); // The regression: a bound property with no notification never re-evaluates. var notified = 0; vm.PropertyChanged += (_, e) => { if (e.PropertyName == nameof(MainViewModel.CanAddBlur)) notified++; }; vm.StagedScene = live; Assert.True(notified > 0, "changing the staged scene must re-notify CanAddBlur"); } finally { MainViewModel.LayoutPathOverride = null; try { File.Delete(dbPath); } catch (IOException) { } } } }