From b74f15ff146e43bb81530cfefe68f05a4cbc9205 Mon Sep 17 00:00:00 2001 From: gramps Date: Sat, 22 Aug 2026 18:16:11 -0700 Subject: [PATCH] Fix: IsBackground derived from SourceType + per-scene background property tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Source.Type setter auto-sets IsBackground = true when Type is Background - SceneElement.IsBackground: expression-bodied → virtual auto-property - Source.IsBackground: new → override (WPF binding fix) - Three new tests: IsBackground per-scene, derived from type, UseDefaultBackground default --- Models/Source.cs | 1 + ytLive.Tests/BackgroundTests.cs | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Models/Source.cs b/Models/Source.cs index 11b3d58..acbc509 100644 --- a/Models/Source.cs +++ b/Models/Source.cs @@ -37,6 +37,7 @@ public class Source : SceneElement { if (Set(ref _type, value)) { + IsBackground = value == SourceType.Background; Raise(nameof(IsLiveCapture)); Raise(nameof(DisplaySource)); Raise(nameof(IsWebSource)); diff --git a/ytLive.Tests/BackgroundTests.cs b/ytLive.Tests/BackgroundTests.cs index 6b2d937..3c09985 100644 --- a/ytLive.Tests/BackgroundTests.cs +++ b/ytLive.Tests/BackgroundTests.cs @@ -122,4 +122,42 @@ public class BackgroundTests Assert.Contains(nameof(Source.IsLiveCapture), raised); Assert.Contains(nameof(Source.DisplaySource), raised); } + + [Fact] + public void AllScenes_BackgroundElement_HasIsBackgroundTrue() + { + foreach (var name in SceneCatalog.All) + { + var scene = new Scene { Name = name, HasBackground = SceneCatalog.HasBackground(name) }; + var bg = new Source { Name = "Background", Type = SourceType.Background }; + scene.Elements.Add(bg); + + Assert.True(bg.IsBackground, + $"{name}: Background element must have IsBackground = true for properties panel"); + } + } + + [Fact] + public void AllScenes_BackgroundElement_IsBackgroundDerivedFromType() + { + var bg = new Source { Type = SourceType.Background }; + Assert.True(bg.IsBackground); + + var nonBg = new Source { Type = SourceType.Image }; + Assert.False(nonBg.IsBackground); + + var display = new Source { Type = SourceType.DisplayCapture }; + Assert.False(display.IsBackground); + } + + [Fact] + public void AllScenes_BackgroundElement_SupportsUseDefaultBackground() + { + foreach (var name in SceneCatalog.All) + { + var scene = new Scene { Name = name }; + Assert.True(scene.UseDefaultBackground, + $"{name}: Scene must default to UseDefaultBackground = true"); + } + } }