64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using Xunit;
|
|
using ytLive.Models;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// The ON-AIR sign (right of REC in the top bar): gray offline, red when
|
|
/// streaming public, green when streaming private. Driven through the real
|
|
/// MainViewModel so StreamStatus/StreamVisibility notification wiring is
|
|
/// exercised, not just the computed property.
|
|
/// </summary>
|
|
[Collection("RealApp")]
|
|
public sealed class OnAirSignTests
|
|
{
|
|
[Fact]
|
|
public void OnAirBrush_Follows_Offline_Public_And_Private()
|
|
{
|
|
_app.Run(Run);
|
|
}
|
|
|
|
private readonly RealAppHost _app;
|
|
|
|
public OnAirSignTests(RealAppHost app) => _app = app;
|
|
|
|
private void Run()
|
|
{
|
|
var tempDb = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"ytLlive-onair-{Guid.NewGuid():N}.db");
|
|
MainViewModel.LayoutPathOverride = tempDb;
|
|
try
|
|
{
|
|
using (var schema = new ytLive.Services.LayoutStore(tempDb)) { }
|
|
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
|
|
|
|
var vm = new MainViewModel();
|
|
|
|
Assert.Equal(StreamStatus.Offline, vm.StreamStatus);
|
|
Assert.Equal("#555555", vm.OnAirBrush);
|
|
|
|
var raised = 0;
|
|
vm.PropertyChanged += (_, e) => { if (e.PropertyName == nameof(MainViewModel.OnAirBrush)) raised++; };
|
|
|
|
vm.StreamVisibility = "Public";
|
|
Assert.Equal("#555555", vm.OnAirBrush);
|
|
|
|
vm.StreamStatus = StreamStatus.Streaming;
|
|
Assert.Equal("#e94560", vm.OnAirBrush);
|
|
|
|
vm.StreamVisibility = "Private";
|
|
Assert.Equal("#22c55e", vm.OnAirBrush);
|
|
|
|
Assert.Equal(3, raised);
|
|
}
|
|
finally
|
|
{
|
|
MainViewModel.LayoutPathOverride = null;
|
|
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
|
|
try { System.IO.File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
|
}
|
|
}
|
|
}
|