| 1 | using CascadeIDE.Features.WorkspaceNavigation.Application; |
| 2 | using Xunit; |
| 3 | |
| 4 | namespace CascadeIDE.Tests; |
| 5 | |
| 6 | public sealed class SemanticMapHciOrientationTests |
| 7 | { |
| 8 | [Theory] |
| 9 | [InlineData(@"D:\repo\src\Foo.cs", "Foo")] |
| 10 | [InlineData("/x/y/Bar.g.cs", "Bar.g")] |
| 11 | [InlineData("NoExt", "NoExt")] |
| 12 | public void BuildQueryFromCurrentPath_returns_file_stem_or_name(string path, string expected) |
| 13 | { |
| 14 | var q = SemanticMapHciOrientationAcquirer.BuildQueryFromCurrentPath(path); |
| 15 | Assert.Equal(expected, q); |
| 16 | } |
| 17 | |
| 18 | [Fact] |
| 19 | public void ToStatusLine_empty_when_no_hits_and_no_error() |
| 20 | { |
| 21 | var s = new SemanticMapHciOrientationSnapshot([], "Foo", null); |
| 22 | Assert.Equal("", SemanticMapHciOrientationFormatting.ToStatusLine(s)); |
| 23 | } |
| 24 | |
| 25 | [Fact] |
| 26 | public void ToStatusLine_shows_error() |
| 27 | { |
| 28 | var s = new SemanticMapHciOrientationSnapshot([], "x", "index missing"); |
| 29 | Assert.Equal("HCI (ориентация): index missing", SemanticMapHciOrientationFormatting.ToStatusLine(s)); |
| 30 | } |
| 31 | |
| 32 | [Fact] |
| 33 | public void ToStatusLine_one_hit() |
| 34 | { |
| 35 | var s = new SemanticMapHciOrientationSnapshot( |
| 36 | [new SemanticMapHciOrientationHit("A.cs", "text_fts", 3, "hello")], |
| 37 | "A", |
| 38 | null); |
| 39 | var line = SemanticMapHciOrientationFormatting.ToStatusLine(s); |
| 40 | Assert.Contains("HCI (ориентация) «A»", line); |
| 41 | Assert.Contains("A.cs:3 (text_fts)", line); |
| 42 | Assert.Contains("hello", line); |
| 43 | } |
| 44 | |
| 45 | [Fact] |
| 46 | public void ToStatusLine_truncates_snippet() |
| 47 | { |
| 48 | var longSn = new string('a', 80); |
| 49 | var s = new SemanticMapHciOrientationSnapshot( |
| 50 | [new SemanticMapHciOrientationHit("B.cs", "text_fts", 1, longSn)], |
| 51 | "B", |
| 52 | null); |
| 53 | var line = SemanticMapHciOrientationFormatting.ToStatusLine(s); |
| 54 | Assert.Contains("…", line); |
| 55 | Assert.DoesNotContain(longSn, line); |
| 56 | } |
| 57 | } |
| 58 | |