forked from microsoft/monitors4codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sync_multilspy_csharp.py
63 lines (53 loc) · 2.43 KB
/
test_sync_multilspy_csharp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
This file contains tests for running the C# Language Server: OmniSharp
"""
from monitors4codegen.multilspy import SyncLanguageServer
from monitors4codegen.multilspy.multilspy_config import Language
from tests.test_utils import create_test_context
from pathlib import PurePath
def test_multilspy_csharp_ryujinx() -> None:
"""
Test the working of multilspy with C# repository - Ryujinx
"""
code_language = Language.CSHARP
params = {
"code_language": code_language,
"repo_url": "https://github.com/Ryujinx/Ryujinx/",
"repo_commit": "e768a54f17b390c3ac10904c7909e3bef020edbd"
}
with create_test_context(params) as context:
lsp = SyncLanguageServer.create(context.config, context.logger, context.source_directory)
# All the communication with the language server must be performed inside the context manager
# The server process is started when the context manager is entered and is terminated when the context manager is exited.
with lsp.start_server():
result = lsp.request_definition(str(PurePath("src/Ryujinx.Audio/Input/AudioInputManager.cs")), 176, 44)
assert isinstance(result, list)
assert len(result) == 1
item = result[0]
assert item["relativePath"] == str(PurePath("src/Ryujinx.Audio/Constants.cs"))
assert item["range"] == {
"start": {"line": 15, "character": 28},
"end": {"line": 15, "character": 50},
}
result = lsp.request_references(str(PurePath("src/Ryujinx.Audio/Constants.cs")), 15, 40)
assert isinstance(result, list)
assert len(result) == 2
for item in result:
del item["uri"]
del item["absolutePath"]
assert result == [
{
"relativePath": str(PurePath("src/Ryujinx.Audio/Input/AudioInputManager.cs")),
"range": {
"start": {"line": 176, "character": 37},
"end": {"line": 176, "character": 59},
},
},
{
"relativePath": str(PurePath("src/Ryujinx.Audio/Input/AudioInputSystem.cs")),
"range": {
"start": {"line": 77, "character": 29},
"end": {"line": 77, "character": 51},
},
},
]