Forge
csharp4405de34
1using Avalonia.Headless.XUnit;
2using CascadeIDE.Cockpit.Composition.HostSurface;
3using CascadeIDE.Features.UiChrome;
4using CascadeIDE.Models;
5using CascadeIDE.ViewModels;
6using Xunit;
7
8namespace CascadeIDE.Tests;
9
10/// <summary>
11/// Регрессия: дерево в колонке PFD и страница «Обозреватель» в MfdShell не должны показываться одновременно из‑за прямого присвоения <see cref="MainWindowViewModel.CurrentMfdShellPage"/>.
12/// </summary>
13[Collection("UiModeCatalog")]
14public sealed class MfdShellSolutionExplorerCoercionTests : IDisposable
15{
16 public MfdShellSolutionExplorerCoercionTests()
17 {
18 UiModeCatalog.ResetForTests();
19 InstrumentPlacementRuntime.ResetToCodeDefaults();
20 }
21
22 public void Dispose()
23 {
24 InstrumentPlacementRuntime.ResetToCodeDefaults();
25 UiModeCatalog.ResetForTests();
26 }
27
28 /// <summary>
29 /// Сценарий «дерево в PFD», не в MFD. Не полагаемся на <see cref="SettingsService.Load"/>:
30 /// в <c>defaults-settings.toml</c> по умолчанию <c>pfd_primary = workspace_map</c>.
31 /// </summary>
32 private static void ApplyTreeInPfdOnlyRouting(DisplaySettings display)
33 {
34 display.Instruments = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
35 {
36 [InstrumentRoutingSlotKeys.PfdPrimary] = CockpitStandardInstrumentIds.SolutionExplorerTree,
37 };
38 }
39
40 [AvaloniaFact]
41 public void Direct_assignment_to_solution_explorer_shell_page_is_coerced_when_tree_is_pfd_docked()
42 {
43 var vm = new MainWindowViewModel();
44 ApplyTreeInPfdOnlyRouting(vm.DisplaySettings);
45 vm.NotifyDockedInstrumentSlotBindings();
46
47 Assert.True(vm.IsDockedPfdSolutionExplorerTree);
48 Assert.False(vm.IsDockedMfdSolutionExplorerTree);
49
50 vm.CurrentMfdShellPage = MfdShellPage.SolutionExplorer;
51
52 Assert.NotEqual(MfdShellPage.SolutionExplorer, vm.CurrentMfdShellPage);
53 Assert.False(vm.IsMfdShellSolutionExplorerPageActive);
54 }
55
56 [AvaloniaFact]
57 public void Solution_explorer_shell_page_stays_when_tree_is_mfd_docked()
58 {
59 var vm = new MainWindowViewModel();
60 vm.DisplaySettings.Instruments = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
61 {
62 [InstrumentRoutingSlotKeys.PfdPrimary] = "workspace_map",
63 [InstrumentRoutingSlotKeys.MfdPrimary] = "solution_explorer_tree",
64 };
65 vm.NotifyDockedInstrumentSlotBindings();
66
67 Assert.False(vm.IsDockedPfdSolutionExplorerTree);
68 Assert.True(vm.IsDockedMfdSolutionExplorerTree);
69
70 vm.TryNavigateToMfdShellPage(MfdShellPage.SolutionExplorer);
71
72 Assert.Equal(MfdShellPage.SolutionExplorer, vm.CurrentMfdShellPage);
73 Assert.True(vm.IsMfdShellSolutionExplorerPageActive);
74 }
75}
76
View only · write via MCP/CIDE