| 1 | using CascadeIDE.Features.Build.Application; |
| 2 | using CascadeIDE.Features.Launch.Application; |
| 3 | using CascadeIDE.Features.UiChrome.Application; |
| 4 | using CascadeIDE.Features.Workspace.Application; |
| 5 | using CascadeIDE.Models; |
| 6 | using Xunit; |
| 7 | |
| 8 | namespace CascadeIDE.Tests; |
| 9 | |
| 10 | public sealed class MainWindowStranglerOrchestratorTests |
| 11 | { |
| 12 | [Fact] |
| 13 | public void StartupProjectRefresh_empty_when_no_solution() |
| 14 | { |
| 15 | var result = StartupProjectRefreshProjection.ResolveAfterSolutionLoad( |
| 16 | null, |
| 17 | [], |
| 18 | @"C:\ws"); |
| 19 | Assert.Equal(StartupProjectRefreshProjection.Empty, result); |
| 20 | } |
| 21 | |
| 22 | [Fact] |
| 23 | public void SolutionLoadUiApply_terminal_when_tree_not_in_mfd_slot() |
| 24 | { |
| 25 | var plan = SolutionLoadUiApplyProjection.Create( |
| 26 | @"C:\a\s.sln", |
| 27 | @"C:\a\s.sln", |
| 28 | isDockedMfdSolutionExplorerTree: false, |
| 29 | PresentationTierKind.Cockpit); |
| 30 | Assert.Equal(MfdShellPage.Terminal, plan.InitialMfdPage); |
| 31 | } |
| 32 | |
| 33 | [Fact] |
| 34 | public void SolutionLoadUiApply_explorer_when_tree_in_mfd_slot() |
| 35 | { |
| 36 | var plan = SolutionLoadUiApplyProjection.Create( |
| 37 | @"C:\a\s.sln", |
| 38 | null, |
| 39 | isDockedMfdSolutionExplorerTree: true, |
| 40 | PresentationTierKind.Cockpit); |
| 41 | Assert.Equal(MfdShellPage.SolutionExplorer, plan.InitialMfdPage); |
| 42 | Assert.Equal(@"C:\a\s.sln", plan.NormalizedSolutionPath); |
| 43 | } |
| 44 | |
| 45 | [Fact] |
| 46 | public void SolutionLoadUiApply_compact_keeps_chat_even_when_tree_in_mfd_slot() |
| 47 | { |
| 48 | var plan = SolutionLoadUiApplyProjection.Create( |
| 49 | @"C:\a\s.sln", |
| 50 | @"C:\a\s.sln", |
| 51 | isDockedMfdSolutionExplorerTree: true, |
| 52 | PresentationTierKind.Compact); |
| 53 | Assert.Equal(MfdShellPage.Chat, plan.InitialMfdPage); |
| 54 | } |
| 55 | |
| 56 | [Fact] |
| 57 | public void BuildSolution_can_build_requires_existing_file() |
| 58 | { |
| 59 | Assert.False(MainWindowBuildSolutionPrepProjection.CanBuild(null, isBuilding: false)); |
| 60 | Assert.False(MainWindowBuildSolutionPrepProjection.CanBuild(@"C:\missing.sln", isBuilding: false)); |
| 61 | Assert.False(MainWindowBuildSolutionPrepProjection.CanBuild(@"C:\x.sln", isBuilding: true)); |
| 62 | } |
| 63 | |
| 64 | [Fact] |
| 65 | public void UiModeLayoutApply_Flight_plan() |
| 66 | { |
| 67 | var plan = UiModeLayoutApplyProjection.Create("Flight", persist: false); |
| 68 | Assert.Equal("Flight", plan.NormalizedMode); |
| 69 | Assert.True(plan.Spec.TerminalVisible); |
| 70 | Assert.Equal(2, plan.Spec.EditorGroupCount); |
| 71 | Assert.Equal( |
| 72 | MfdShellPage.Build, |
| 73 | UiModeLayoutApplyProjection.ResolveMfdPageAfterApply(plan, MfdShellPage.Build)); |
| 74 | |
| 75 | var terminalTabPlan = new UiModeLayoutApplyProjection.Plan( |
| 76 | plan.Spec with { SelectTerminalTabWhenTerminalShown = true }, |
| 77 | plan.NormalizedMode, |
| 78 | plan.Persist); |
| 79 | Assert.Equal( |
| 80 | MfdShellPage.Terminal, |
| 81 | UiModeLayoutApplyProjection.ResolveMfdPageAfterApply(terminalTabPlan, MfdShellPage.Build)); |
| 82 | } |
| 83 | } |
| 84 | |