diff --git a/Services/LayoutStore.Load.cs b/Services/LayoutStore.Load.cs index 8775c9b..22cfdb4 100644 --- a/Services/LayoutStore.Load.cs +++ b/Services/LayoutStore.Load.cs @@ -111,7 +111,7 @@ public partial class LayoutStore : IDisposable ChatShowTimestamps, ChatShowBadges, ChatMemberColor, ChatSuperChatColor, WebUri, MediaPath, MediaIsLooping, MediaVolume, MediaPlaybackState, AlertVideoAssetId, AlertVideoPath, AlertUseDefaultVideo, AlertShowTicker, AlertVideoVolume, SortOrder, - AlertDisplayMethod, IsBrandLogo + AlertDisplayMethod, IsBrandLogo, BlurAmount FROM Source ORDER BY SortOrder """; using var reader = cmd.ExecuteReader(); diff --git a/ytLive.Tests/LayoutBlurPersistenceTests.cs b/ytLive.Tests/LayoutBlurPersistenceTests.cs new file mode 100644 index 0000000..c5dae1f --- /dev/null +++ b/ytLive.Tests/LayoutBlurPersistenceTests.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using Xunit; +using ytLive.Models; +using ytLive.Services; + +namespace ytLive.Tests; + +/// +/// The blur column round-trips through SQLite (2026-11-01). This exists because the first cut +/// added `BlurAmount` to the INSERT and the reader but not to the SELECT — the app then crashed on +/// launch inside `GetOrdinal("BlurAmount")`, which is a startup path no other test covers. +/// +public class LayoutBlurPersistenceTests +{ + [Fact] + public void A_blur_layer_survives_a_save_and_reload_with_its_amount() + { + var dbPath = Path.Combine(Path.GetTempPath(), $"llamacasty-blur-{Guid.NewGuid():N}.db"); + try + { + var scenes = new ObservableCollection + { + new() { Name = SceneCatalog.Live }, + }; + var background = new Source { Name = "Background", Type = SourceType.Background, IsBackground = true, Width = 1920, Height = 1080 }; + var blur = new Source { Name = "Blur", Type = SourceType.Blur, X = 40, Y = 50, Width = 240, Height = 160, BlurAmount = 0.8 }; + scenes[0].Elements.Add(background); + scenes[0].Elements.Add(blur); + + using (var store = new LayoutStore(dbPath)) + store.Save(scenes, null, null); + + using (var reopened = new LayoutStore(dbPath)) + { + var loaded = reopened.Load(); + var loadedBlur = loaded.SelectMany(s => s.Elements).OfType().Single(s => s.Type == SourceType.Blur); + Assert.Equal(0.8, loadedBlur.BlurAmount, 3); + Assert.Equal(240, loadedBlur.Width, 3); + Assert.Equal(SourceType.Blur, loadedBlur.Type); + } + } + finally + { + try { File.Delete(dbPath); } catch (IOException) { } + } + } +}