Forge
csharpdeeb25a2
1using Avalonia;
2using CascadeIDE.Cockpit.Graph.Layout;
3using CascadeIDE.Models;
4using CascadeIDE.Services;
5using CascadeIDE.ViewModels;
6using Xunit;
7
8namespace CascadeIDE.Tests;
9
10public sealed class EditorControlFlowLanePolicyTests
11{
12 [Fact]
13 public void ShouldReserveLane_false_when_not_control_flow_level()
14 {
15 var scene = MinimalCfScene();
16 Assert.False(EditorControlFlowLanePolicy.ShouldReserveLane(
17 CodeNavigationMapLevelKind.File,
18 @"D:\w\A.cs",
19 @"D:\w\A.cs",
20 scene));
21 }
22
23 [Fact]
24 public void ShouldReserveLane_false_when_anchor_mismatch()
25 {
26 var scene = MinimalCfScene();
27 Assert.False(EditorControlFlowLanePolicy.ShouldReserveLane(
28 CodeNavigationMapLevelKind.ControlFlow,
29 @"D:\w\A.cs",
30 @"D:\w\B.cs",
31 scene));
32 }
33
34 [Fact]
35 public void ShouldReserveLane_true_when_cf_scene_for_same_file()
36 {
37 const string path = @"D:\w\A.cs";
38 var scene = MinimalCfScene();
39 Assert.True(EditorControlFlowLanePolicy.ShouldReserveLane(
40 CodeNavigationMapLevelKind.ControlFlow,
41 path,
42 path,
43 scene));
44 }
45
46 [Fact]
47 public void LaneWidthPixels_fits_glyph_diameter_plus_padding()
48 {
49 double expected = EditorControlFlowLanePolicy.GlyphRadius * 2
50 + EditorControlFlowLanePolicy.LanePadding * 2;
51 Assert.Equal(EditorControlFlowLanePolicy.LaneWidthPixels, expected);
52 }
53
54 private static CodeNavigationMapGraphSceneVm MinimalCfScene() =>
55 new()
56 {
57 Presentation = CodeNavigationMapGraphPresentationKind.CodeControlFlow,
58 Nodes =
59 [
60 new CodeNavigationMapGraphNodeLayout
61 {
62 Id = "n0",
63 FullPath = @"D:\w\A.cs",
64 Kind = "anchor",
65 Label = "A.cs",
66 IsAnchor = true,
67 Center = new Point(40, 40),
68 Radius = 8
69 }
70 ],
71 Edges = [],
72 ControlFlowMainAxis = GraphControlFlowMainAxis.Vertical
73 };
74}
75
View only · write via MCP/CIDE