fix(blur): the crash on launch — BlurAmount was in the INSERT and the reader, not the SELECT
LayoutStore.Load threw ArgumentOutOfRangeException on GetOrdinal("BlurAmount") during the
MainViewModel constructor, so the app died at startup rather than when a blur was used. The
migration adds the column and Save writes it; the reading query still listed its columns
explicitly and BlurAmount was missing from that list.
Adds LayoutBlurPersistenceTests: a blur saved and reloaded, asserting the amount and geometry
survive. That is the test that should have existed with the feature — the startup path it
covers has no other guard.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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<Scene>
|
||||
{
|
||||
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<Source>().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) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user