Forge
csharp4405de34
1#nullable enable
2using Avalonia;
3using CascadeIDE.Cockpit.Graph.Layout;
4using CascadeIDE.Views.SkiaKit.Graph;
5using Xunit;
6
7namespace CascadeIDE.Tests;
8
9public sealed class SkiaGraphSceneHitTestingTests
10{
11 [Fact]
12 public void FindNodeAt_prefers_topmost_when_nodes_overlap()
13 {
14 var scene = new GraphLayoutScene
15 {
16 Nodes =
17 [
18 new GraphLayoutNode
19 {
20 Id = "back",
21 Kind = "call_step",
22 FullPath = "a.cs",
23 Label = "A",
24 Center = new Point(50, 50),
25 Radius = 20,
26 IsAnchor = false
27 },
28 new GraphLayoutNode
29 {
30 Id = "front",
31 Kind = "call_step",
32 FullPath = "b.cs",
33 Label = "B",
34 Center = new Point(52, 52),
35 Radius = 20,
36 IsAnchor = false
37 }
38 ],
39 Edges = [],
40 Legend = [],
41 LegendColumnLeft = 200
42 };
43
44 var hit = SkiaGraphSceneHitTesting.FindNodeAt(scene, new Point(52, 52));
45 Assert.NotNull(hit);
46 Assert.Equal("front", hit!.Id);
47 }
48
49 [Fact]
50 public void MapControlPointToLayout_scales_when_control_smaller_than_layout()
51 {
52 var mapped = SkiaGraphSceneHitTesting.MapControlPointToLayout(
53 new Point(50, 100),
54 controlWidth: 100,
55 controlHeight: 200,
56 layoutViewportWidth: 200,
57 layoutViewportHeight: 400);
58
59 Assert.Equal(100, mapped.X, 3);
60 Assert.Equal(200, mapped.Y, 3);
61 }
62}
63
View only · write via MCP/CIDE