| 1 | using CascadeIDE.Features.Editor.Application.Monaco; |
| 2 | using CascadeIDE.Services; |
| 3 | using CascadeIDE.ViewModels; |
| 4 | using Xunit; |
| 5 | |
| 6 | namespace CascadeIDE.Tests; |
| 7 | |
| 8 | public sealed class MonacoEditorM9MapperTests |
| 9 | { |
| 10 | [Fact] |
| 11 | public void InlayMapper_converts_offset_to_line_column() |
| 12 | { |
| 13 | const string text = "var x = 1;\nvar y = 2;"; |
| 14 | var parts = new[] { new EditorTrailingInlayPart(3, " int") }; |
| 15 | var hints = MonacoEditorInlayMapper.ToHints(text, parts); |
| 16 | Assert.Single(hints); |
| 17 | Assert.Equal(1, hints[0].Line); |
| 18 | Assert.Equal(4, hints[0].Column); |
| 19 | } |
| 20 | |
| 21 | [Fact] |
| 22 | public void CodeLensComposer_emits_nodes_with_line_start() |
| 23 | { |
| 24 | const string path = @"D:\w\A.cs"; |
| 25 | var scene = new CodeNavigationMapGraphSceneVm |
| 26 | { |
| 27 | Presentation = CodeNavigationMapGraphPresentationKind.CodeControlFlow, |
| 28 | Nodes = |
| 29 | [ |
| 30 | new CodeNavigationMapGraphNodeLayout |
| 31 | { |
| 32 | Id = "n1", |
| 33 | FullPath = path, |
| 34 | Kind = "step", |
| 35 | Label = "DoWork", |
| 36 | IsAnchor = false, |
| 37 | Center = new Avalonia.Point(10, 10), |
| 38 | Radius = 6, |
| 39 | LineStart = 42, |
| 40 | LegendIndex = 3, |
| 41 | }, |
| 42 | ], |
| 43 | Edges = [], |
| 44 | }; |
| 45 | |
| 46 | var lenses = MonacoEditorCodeLensComposer.FromNavigationScene(path, scene); |
| 47 | Assert.Single(lenses); |
| 48 | Assert.Equal("n1", lenses[0].Id); |
| 49 | Assert.Equal(42, lenses[0].Line); |
| 50 | Assert.Contains("DoWork", lenses[0].Title); |
| 51 | } |
| 52 | } |
| 53 | |