using Xunit; using ytLive.Models; using ytLive.ViewModels; namespace ytLive.Tests; /// /// The app is a five-scene product: Starting/Live/BRB/Chat/Ending. Scenes are /// worked on by name; you can delete them but never add beyond the set, and the /// live background belongs to Live alone. /// public class SceneCatalogTests { [Fact] public void SceneCatalog_Defines_The_Five_Canonical_Scenes() { Assert.Equal( new[] { "Starting", "Live", "BRB", "Chat", "Ending" }, SceneCatalog.All); } [Theory] [InlineData("Starting", true)] [InlineData("Live", true)] [InlineData("BRB", true)] [InlineData("Chat", true)] [InlineData("Ending", true)] [InlineData("live", true)] [InlineData("My Scene", false)] [InlineData("", false)] [InlineData(null, false)] public void SceneCatalog_IsCanonical_Matches_By_Name(string? name, bool expected) { Assert.Equal(expected, SceneCatalog.IsCanonical(name)); } [Theory] [InlineData("Starting", true)] [InlineData("Live", true)] [InlineData("BRB", true)] [InlineData("Chat", true)] [InlineData("Ending", true)] public void SceneCatalog_HasBackground_For_All_Canonical_Scenes(string name, bool expected) { Assert.Equal(expected, SceneCatalog.HasBackground(name)); } [Fact] public void EnforceBackgroundPolicy_Sets_Flag_For_All_Scenes() { var chat = new Scene { Name = "Chat", HasBackground = false }; var live = new Scene { Name = "Live", HasBackground = false }; var chatBackground = MainViewModel.EnsureBackground(chat)!; var liveBackground = MainViewModel.EnsureBackground(live)!; MainViewModel.EnforceBackgroundPolicy(new[] { chat, live }); Assert.True(chat.HasBackground); Assert.Contains(chat.Elements, e => ReferenceEquals(e, chatBackground)); Assert.True(live.HasBackground); Assert.Contains(live.Elements, e => ReferenceEquals(e, liveBackground)); } [Fact] public void EnforceBackgroundPolicy_Normalizes_All_Canonical_Scenes() { var starting = new Scene { Name = "Starting", HasBackground = false }; MainViewModel.EnsureBackground(starting); var live = new Scene { Name = "Live", HasBackground = false }; MainViewModel.EnforceBackgroundPolicy(new[] { starting, live }); Assert.True(starting.HasBackground); Assert.True(live.HasBackground); } }