Forge
csharpdeeb25a2
1using CascadeIDE.Features.Workspace;
2using CascadeIDE.Features.Workspace.Application;
3using CascadeIDE.Models;
4using Xunit;
5
6namespace CascadeIDE.Tests;
7
8public sealed class SolutionLoadSessionApplyProjectionTests
9{
10 [Fact]
11 public void ApplySuccessfulLoad_updates_workspace_and_calls_host()
12 {
13 var workspace = new SolutionWorkspaceViewModel();
14 var root = SolutionItem.CreateSolution("App", @"C:\repo\App.sln");
15 var host = new RecordingHost();
16
17 SolutionLoadSessionApplyProjection.ApplySuccessfulLoad(
18 workspace,
19 root,
20 @"C:\repo\App.sln",
21 @"C:\repo\App.sln",
22 isDockedMfdSolutionExplorerTree: false,
23 PresentationTierKind.Cockpit,
24 host);
25
26 Assert.Equal(@"C:\repo\App.sln", workspace.SolutionPath);
27 Assert.Single(workspace.SolutionRoots);
28 Assert.Equal(root, workspace.SolutionRoots[0]);
29 Assert.Null(workspace.SelectedSolutionItem);
30 Assert.True(host.ResetCalled);
31 Assert.Equal(MfdShellPage.Terminal, host.InitialPage);
32 }
33
34 [Fact]
35 public void ApplySuccessfulLoad_docked_explorer_uses_solution_explorer_page()
36 {
37 var workspace = new SolutionWorkspaceViewModel();
38 var root = SolutionItem.CreateSolution("App", @"C:\repo\App.sln");
39 var host = new RecordingHost();
40
41 SolutionLoadSessionApplyProjection.ApplySuccessfulLoad(
42 workspace,
43 root,
44 @"C:\repo\App.sln",
45 @"C:\repo\App.sln",
46 isDockedMfdSolutionExplorerTree: true,
47 PresentationTierKind.Cockpit,
48 host);
49
50 Assert.Equal(MfdShellPage.SolutionExplorer, host.InitialPage);
51 }
52
53 [Fact]
54 public void ApplySuccessfulLoad_compact_keeps_chat_page()
55 {
56 var workspace = new SolutionWorkspaceViewModel();
57 var root = SolutionItem.CreateSolution("App", @"C:\repo\App.sln");
58 var host = new RecordingHost();
59
60 SolutionLoadSessionApplyProjection.ApplySuccessfulLoad(
61 workspace,
62 root,
63 @"C:\repo\App.sln",
64 @"C:\repo\App.sln",
65 isDockedMfdSolutionExplorerTree: true,
66 PresentationTierKind.Compact,
67 host);
68
69 Assert.Equal(MfdShellPage.Chat, host.InitialPage);
70 }
71
72 private sealed class RecordingHost : SolutionLoadSessionApplyProjection.IHost
73 {
74 public bool ResetCalled { get; private set; }
75
76 public MfdShellPage InitialPage { get; private set; }
77
78 public void ResetEditorSessionForNewSolution() => ResetCalled = true;
79
80 public void AfterSolutionApplied(MfdShellPage initialMfdPage) => InitialPage = initialMfdPage;
81 }
82}
83
View only · write via MCP/CIDE