|
| 1 | +; ========================= |
| 2 | +; Test method with namespace |
| 3 | +; ========================= |
| 4 | +( |
| 5 | + (namespace_declaration |
| 6 | + name: (_) @csharp_namespace |
| 7 | + body: (declaration_list |
| 8 | + (class_declaration |
| 9 | + name: (identifier) @csharp_class_name @csharp_csproj_hint |
| 10 | + body: (declaration_list |
| 11 | + (method_declaration |
| 12 | + (attribute_list |
| 13 | + (attribute |
| 14 | + name: (_) @attribute_name |
| 15 | + (#match? @attribute_name "^(Fact|Theory|Test|TestCase|TestCaseSource|TestMethod|DataTestMethod)$"))) |
| 16 | + name: (identifier) @run @csharp_method_name))))) |
| 17 | + (#set! tag csharp-test-method) |
| 18 | +) |
| 19 | + |
| 20 | +; ====================================== |
| 21 | +; Test method with file-scoped namespace |
| 22 | +; ====================================== |
| 23 | +( |
| 24 | + (file_scoped_namespace_declaration |
| 25 | + name: (_) @csharp_namespace |
| 26 | + (class_declaration |
| 27 | + name: (identifier) @csharp_class_name @csharp_csproj_hint |
| 28 | + body: (declaration_list |
| 29 | + (method_declaration |
| 30 | + (attribute_list |
| 31 | + (attribute |
| 32 | + name: (_) @attribute_name |
| 33 | + (#match? @attribute_name "^(Fact|Theory|Test|TestCase|TestCaseSource|TestMethod|DataTestMethod)$"))) |
| 34 | + name: (identifier) @run @csharp_method_name)))) |
| 35 | + (#set! tag csharp-test-method) |
| 36 | +) |
| 37 | + |
| 38 | +; ============================ |
| 39 | +; Test method without namespace |
| 40 | +; (anchored to top-level only) |
| 41 | +; ============================ |
| 42 | +( |
| 43 | + (compilation_unit |
| 44 | + (class_declaration |
| 45 | + name: (identifier) @csharp_class_name @csharp_csproj_hint |
| 46 | + body: (declaration_list |
| 47 | + (method_declaration |
| 48 | + (attribute_list |
| 49 | + (attribute |
| 50 | + name: (_) @attribute_name |
| 51 | + (#match? @attribute_name "^(Fact|Theory|Test|TestCase|TestCaseSource|TestMethod|DataTestMethod)$"))) |
| 52 | + name: (identifier) @run @csharp_method_name)))) |
| 53 | + (#set! tag csharp-test-method) |
| 54 | +) |
| 55 | + |
| 56 | +; =============================== |
| 57 | +; Test class with namespace |
| 58 | +; =============================== |
| 59 | +( |
| 60 | + (namespace_declaration |
| 61 | + name: (_) @csharp_namespace |
| 62 | + body: (declaration_list |
| 63 | + (class_declaration |
| 64 | + (attribute_list |
| 65 | + (attribute |
| 66 | + name: (_) @class_attribute |
| 67 | + (#match? @class_attribute "^(TestFixture|TestClass)$"))) |
| 68 | + name: (identifier) @run @csharp_class_name))) |
| 69 | + (#set! tag csharp-test-class) |
| 70 | +) |
| 71 | + |
| 72 | +; ===================================== |
| 73 | +; Test class with file-scoped namespace |
| 74 | +; ===================================== |
| 75 | +( |
| 76 | + (file_scoped_namespace_declaration |
| 77 | + name: (_) @csharp_namespace |
| 78 | + (class_declaration |
| 79 | + (attribute_list |
| 80 | + (attribute |
| 81 | + name: (_) @class_attribute |
| 82 | + (#match? @class_attribute "^(TestFixture|TestClass)$"))) |
| 83 | + name: (identifier) @run @csharp_class_name)) |
| 84 | + (#set! tag csharp-test-class) |
| 85 | +) |
| 86 | + |
| 87 | +; ============================== |
| 88 | +; Test class without namespace |
| 89 | +; (anchored to top-level only) |
| 90 | +; ============================== |
| 91 | +( |
| 92 | + (compilation_unit |
| 93 | + (class_declaration |
| 94 | + (attribute_list |
| 95 | + (attribute |
| 96 | + name: (_) @class_attribute |
| 97 | + (#match? @class_attribute "^(TestFixture|TestClass)$"))) |
| 98 | + name: (identifier) @run @csharp_class_name)) |
| 99 | + (#set! tag csharp-test-class) |
| 100 | +) |
0 commit comments