Forge
csharpdeeb25a2
1using CascadeIDE.Services;
2using Xunit;
3
4namespace CascadeIDE.Tests;
5
6public sealed class CodeNavigationKindFilterTests
7{
8 [Fact]
9 public void Create_Default_Allows_All_Kinds()
10 {
11 var f = CodeNavigationKindFilter.Create(null, null);
12 Assert.True(f.Allows(CodeNavigationRelatedKinds.ProjectPeer));
13 Assert.True(f.Allows(CodeNavigationRelatedKinds.SameNamespace));
14 }
15
16 [Fact]
17 public void Exclude_Removes_Kind()
18 {
19 var f = CodeNavigationKindFilter.Create(null, ["same_namespace", "same_directory"]);
20 Assert.True(f.Allows(CodeNavigationRelatedKinds.ProjectPeer));
21 Assert.False(f.Allows(CodeNavigationRelatedKinds.SameNamespace));
22 Assert.False(f.Allows(CodeNavigationRelatedKinds.SameDirectory));
23 }
24
25 [Fact]
26 public void Include_Whitelist_Only()
27 {
28 var f = CodeNavigationKindFilter.Create(["project_peer", "partial_peer"], null);
29 Assert.True(f.Allows(CodeNavigationRelatedKinds.ProjectPeer));
30 Assert.True(f.Allows(CodeNavigationRelatedKinds.PartialPeer));
31 Assert.False(f.Allows(CodeNavigationRelatedKinds.TestCounterpart));
32 }
33
34 [Fact]
35 public void Include_And_Exclude_Compose()
36 {
37 var f = CodeNavigationKindFilter.Create(["project_peer", "test_counterpart"], ["test_counterpart"]);
38 Assert.True(f.Allows(CodeNavigationRelatedKinds.ProjectPeer));
39 Assert.False(f.Allows(CodeNavigationRelatedKinds.TestCounterpart));
40 }
41
42 [Fact]
43 public void Unknown_Tokens_In_Lists_Are_Ignored()
44 {
45 var f = CodeNavigationKindFilter.Create(["not_a_kind", "PROJECT_PEER"], null);
46 Assert.True(f.Allows(CodeNavigationRelatedKinds.ProjectPeer));
47 Assert.False(f.Allows(CodeNavigationRelatedKinds.SameNamespace));
48 }
49
50 [Fact]
51 public void Include_Only_Unknown_Falls_Back_To_All()
52 {
53 var f = CodeNavigationKindFilter.Create(["typo", "nope"], null);
54 Assert.True(f.Allows(CodeNavigationRelatedKinds.SameNamespace));
55 }
56
57 [Fact]
58 public void Effective_Include_Is_Null_When_Unrestricted()
59 {
60 var f = CodeNavigationKindFilter.Create(null, null);
61 Assert.Null(f.EffectiveIncludeKinds);
62 }
63
64 [Fact]
65 public void Effective_Include_Lists_Canonical_Names()
66 {
67 var f = CodeNavigationKindFilter.Create(["PROJECT_PEER", "partial_peer"], null);
68 Assert.NotNull(f.EffectiveIncludeKinds);
69 Assert.Equal(2, f.EffectiveIncludeKinds!.Count);
70 Assert.Equal(CodeNavigationRelatedKinds.PartialPeer, f.EffectiveIncludeKinds[0]);
71 Assert.Equal(CodeNavigationRelatedKinds.ProjectPeer, f.EffectiveIncludeKinds[1]);
72 }
73
74 [Fact]
75 public void Effective_Exclude_Is_Empty_When_None()
76 {
77 var f = CodeNavigationKindFilter.Create(null, null);
78 Assert.NotNull(f.EffectiveExcludeKinds);
79 Assert.Empty(f.EffectiveExcludeKinds);
80 }
81}
82
View only · write via MCP/CIDE