Skip to content

Commit 115e4a1

Browse files
authored
Merge pull request #7481 from dibarbet/implementation_tests
Add go to implementation integration test
2 parents b47f2c4 + a4a36b7 commit 115e4a1

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as vscode from 'vscode';
7+
import * as path from 'path';
8+
import testAssetWorkspace from './testAssets/testAssetWorkspace';
9+
import {
10+
activateCSharpExtension,
11+
closeAllEditorsAsync,
12+
openFileInWorkspaceAsync,
13+
sortLocations,
14+
} from './integrationHelpers';
15+
import { describe, beforeAll, beforeEach, afterAll, test, expect, afterEach } from '@jest/globals';
16+
17+
describe(`[${testAssetWorkspace.description}] Test Go To Implementation`, () => {
18+
beforeAll(async () => {
19+
await activateCSharpExtension();
20+
});
21+
22+
beforeEach(async () => {
23+
await openFileInWorkspaceAsync(path.join('src', 'app', 'implementation.cs'));
24+
});
25+
26+
afterAll(async () => {
27+
await testAssetWorkspace.cleanupWorkspace();
28+
});
29+
30+
afterEach(async () => {
31+
await closeAllEditorsAsync();
32+
});
33+
34+
test('Finds implementations', async () => {
35+
const requestPosition = new vscode.Position(4, 22);
36+
const implementationList = await getImplementations(requestPosition);
37+
38+
expect(implementationList).toHaveLength(3);
39+
40+
expect(implementationList[0].uri.path).toContain('BaseClassImplementation.cs');
41+
expect(implementationList[0].range).toStrictEqual(new vscode.Range(2, 17, 2, 40));
42+
43+
expect(implementationList[1].uri.path).toContain('implementation.cs');
44+
expect(implementationList[1].range).toStrictEqual(new vscode.Range(4, 17, 4, 26));
45+
46+
expect(implementationList[2].uri.path).toContain('implementation.cs');
47+
expect(implementationList[2].range).toStrictEqual(new vscode.Range(5, 17, 5, 26));
48+
});
49+
});
50+
51+
async function getImplementations(position: vscode.Position): Promise<vscode.Location[]> {
52+
const implementationList = <vscode.Location[]>(
53+
await vscode.commands.executeCommand(
54+
'vscode.executeImplementationProvider',
55+
vscode.window.activeTextEditor!.document.uri,
56+
position
57+
)
58+
);
59+
60+
return sortLocations(implementationList);
61+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace minimal
2+
{
3+
public class BaseClassImplementation : BaseClass
4+
{
5+
}
6+
}

test/integrationTests/testAssets/slnWithCsproj/src/app/SomeInterfaceImpl.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)