using System; using System.IO; using Xunit; using ytLive.ViewModels; namespace ytLive.Tests; /// /// Three activities, always visible (creator, 2026-11-13): build, stream, record. The active one is lit /// and runs its own flow in place; the other two stay on the bar and dim, so there is no state where the /// creator cannot see where they are or how to step back. /// [Collection("MainViewModelLayoutPath")] public class TopBarActivityTests { private static MainViewModel NewVm(string db) { MainViewModel.LayoutPathOverride = db; return new MainViewModel(); } [Fact] public void Three_activities_stay_on_the_bar_and_the_active_one_owns_its_flow() { var db = Path.Combine(Path.GetTempPath(), $"llamacasty-activity-{Guid.NewGuid():N}.db"); try { var vm = NewVm(db); // Launch: Build is the activity and the only one editing. Assert.Equal(TopActivity.Build, vm.Activity); Assert.True(vm.IsBuildActivity); Assert.True(vm.IsEditMode); Assert.False(vm.IsRecording); // Record: its own flow becomes Start, and editing steps aside. vm.SelectRecordActivityCommand.Execute(null); Assert.True(vm.IsRecordActivity); Assert.False(vm.IsEditMode); Assert.True(vm.ShowRecordStart); Assert.False(vm.ShowRecordStop); Assert.Equal("Start Recording", vm.RecordActionLabel); // Recording swaps the flow to Stop, and the elapsed label carries REC. vm.IsRecording = true; Assert.False(vm.ShowRecordStart); Assert.True(vm.ShowRecordStop); Assert.Equal("Stop Recording", vm.RecordActionLabel); Assert.StartsWith("REC: ", vm.RecordElapsedLabel); vm.IsRecording = false; // YouTube: choosing Live only ARMS it. Start is a second press — the "are you ready?" moment. vm.SelectYouTubeActivityCommand.Execute(null); Assert.True(vm.IsYouTubeActivity); Assert.True(vm.ShowYouTubeModeChoices); Assert.False(vm.ShowYouTubeStart); vm.ChooseLiveModeCommand.Execute(null); Assert.True(vm.IsLiveModeChosen); Assert.False(vm.ShowYouTubeModeChoices); Assert.True(vm.ShowYouTubeStart); vm.ChoosePrivateModeCommand.Execute(null); Assert.True(vm.IsPrivateModeChosen); Assert.False(vm.IsLiveModeChosen); // Back to Build: editing returns, and the YouTube choice is forgotten, not carried. vm.SelectBuildActivityCommand.Execute(null); Assert.True(vm.IsBuildActivity); Assert.True(vm.IsEditMode); Assert.False(vm.ShowYouTubeModeChoices); Assert.False(vm.ShowYouTubeStart); } finally { MainViewModel.LayoutPathOverride = null; try { File.Delete(db); } catch (IOException) { } } } }