using System; using System.IO; using Xunit; using ytLive.ViewModels; namespace ytLive.Tests; /// /// The bar is three FIXED SLOTS (creator, 2026-11-13). Each slot owns its own flow and mutates only its /// own interior, so neighbouring buttons never move; and while either action slot is past Idle, Build /// Scenes is locked. /// [Collection("MainViewModelLayoutPath")] public class TopBarSlotTests { [Fact] public void Each_slot_runs_its_own_flow_in_place_and_build_locks_while_they_do() { var db = Path.Combine(Path.GetTempPath(), $"llamacasty-slots-{Guid.NewGuid():N}.db"); MainViewModel.LayoutPathOverride = db; try { var vm = new MainViewModel(); // All three idle: YouTube and Record are single buttons, Build is live. Assert.True(vm.IsYouTubeIdle); Assert.True(vm.IsRecordIdle); Assert.True(vm.IsBuildScenesEnabled); Assert.Contains("Edit layers", vm.BuildScenesTooltip); // YouTube: idle -> choose privacy -> armed -> (start) streaming. vm.OpenYouTubeCommand.Execute(null); Assert.True(vm.IsYouTubeChoosingPrivacy); Assert.False(vm.IsBuildScenesEnabled); Assert.Contains("locked", vm.BuildScenesTooltip); vm.ChoosePrivateCommand.Execute(null); Assert.True(vm.IsYouTubeArmed); Assert.Equal("Start Private", vm.YouTubeArmLabel); vm.ChooseLiveCommand.Execute(null); // switching choice while armed is allowed Assert.Equal("Start Live", vm.YouTubeArmLabel); // Cancel returns that slot to Idle — and Build unlocks because both slots are idle again. vm.CancelYouTubeCommand.Execute(null); Assert.True(vm.IsYouTubeIdle); Assert.True(vm.IsBuildScenesEnabled); // Record: idle -> armed -> (start) recording, with the clock carrying REC. vm.OpenRecordCommand.Execute(null); Assert.True(vm.IsRecordArmed); Assert.False(vm.IsBuildScenesEnabled); vm.StartRecordingCommand.Execute(null); Assert.True(vm.IsRecordRecording); Assert.StartsWith("REC: ", vm.RecordElapsedLabel); vm.StopRecordingCommand.Execute(null); Assert.True(vm.IsRecordIdle); Assert.True(vm.IsBuildScenesEnabled); } finally { MainViewModel.LayoutPathOverride = null; try { File.Delete(db); } catch (IOException) { } } } }