using System;
using System.Linq;
using Xunit;
using ytLive.Models;
using ytLive.Services;
using ytLive.ViewModels;
namespace ytLive.Tests;
///
/// The brand logo is one locked image layer per scene, directly above the background.
///
[Collection("RealApp")]
public sealed class BrandLogoTests
{
private readonly RealAppHost _app;
public BrandLogoTests(RealAppHost app) => _app = app;
[Fact]
public void Every_Scene_Gets_One_Brand_Logo_Directly_Above_The_Background()
{
_app.Run(Run);
}
private static void Run()
{
var tempDb = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"ytLlive-brand-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = tempDb;
try
{
using (var schema = new LayoutStore(tempDb)) { }
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
var vm = new MainViewModel();
foreach (var scene in vm.Scenes)
{
var logos = scene.Elements.OfType().Where(s => s.IsBrandLogo).ToList();
Assert.Single(logos);
var index = scene.Elements.IndexOf(logos[0]);
var background = scene.Elements.OfType().First(s => s.IsBackground);
Assert.Equal(scene.Elements.IndexOf(background) + 1, index);
}
var staged = vm.StagedScene!;
var logo = staged.Elements.OfType().First(s => s.IsBrandLogo);
vm.RemoveElement(logo);
Assert.Contains(logo, staged.Elements);
}
finally
{
MainViewModel.LayoutPathOverride = null;
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
try { System.IO.File.Delete(tempDb); } catch { }
}
}
}