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) { } } } }