using System;
using System.ComponentModel;
using Xunit;
using ytLive.Services;
using ytLive.ViewModels;
namespace ytLive.Tests;
///
/// The App Settings transition picker drives the view model: type and length changes
/// notify the bound controls.
///
[Collection("RealApp")]
public sealed class TransitionPickerTests
{
private readonly RealAppHost _app;
public TransitionPickerTests(RealAppHost app) => _app = app;
[Fact]
public void Transition_Type_And_Length_Notify_The_Settings_Picker()
{
_app.Run(Run);
}
private static void Run()
{
var tempDb = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"ytLlive-transition-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = tempDb;
try
{
using (var schema = new LayoutStore(tempDb)) { }
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
var vm = new MainViewModel();
var raised = new System.Collections.Generic.List();
((INotifyPropertyChanged)vm).PropertyChanged += (_, e) => raised.Add(e.PropertyName ?? "");
vm.SelectedTransitionType = TransitionType.Move;
vm.TransitionDurationMs = 750;
Assert.Equal(TransitionType.Move, vm.SelectedTransitionType);
Assert.Equal(750, vm.TransitionDurationMs);
Assert.Contains(nameof(MainViewModel.SelectedTransitionType), raised);
Assert.Contains(nameof(MainViewModel.TransitionDurationMs), raised);
}
finally
{
MainViewModel.LayoutPathOverride = null;
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
try { System.IO.File.Delete(tempDb); } catch { }
}
}
}