From f44c31d02933098f535b8f16bc1fdb78b268f3b7 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 4 Jul 2018 16:44:03 -0700 Subject: [PATCH 1/2] Test for the implementation provider --- .../implementationProvider.test.ts | 37 +++++++++++++++++++ .../testAssets/singleCsproj/implementation.cs | 7 ++++ .../slnWithCsproj/src/app/implementation.cs | 7 ++++ 3 files changed, 51 insertions(+) create mode 100644 test/integrationTests/implementationProvider.test.ts create mode 100644 test/integrationTests/testAssets/singleCsproj/implementation.cs create mode 100644 test/integrationTests/testAssets/slnWithCsproj/src/app/implementation.cs diff --git a/test/integrationTests/implementationProvider.test.ts b/test/integrationTests/implementationProvider.test.ts new file mode 100644 index 000000000..15db8d0b9 --- /dev/null +++ b/test/integrationTests/implementationProvider.test.ts @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import * as vscode from "vscode"; +import CSharpImplementationProvider from "../../src/features/implementationProvider"; +import CSharpExtensionExports from "../../src/CSharpExtensionExports"; +import * as path from "path"; +import testAssetWorkspace from "./testAssets/testAssetWorkspace"; +import { expect } from "chai"; + +suite(`${CSharpImplementationProvider.name}: ${testAssetWorkspace.description}`, () => { + let fileUri: vscode.Uri; + + suiteSetup(async () => { + let csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp"); + if (!csharpExtension.isActive) { + await csharpExtension.activate(); + } + + await csharpExtension.exports.initializationFinished(); + let fileName = 'implementation.cs'; + let dir = path.dirname(testAssetWorkspace.projects[0].projectDirectoryPath); + fileUri = vscode.Uri.file(path.join(dir, fileName)); + await vscode.commands.executeCommand("vscode.open", fileUri); + }); + + suiteTeardown(async () => { + await testAssetWorkspace.cleanupWorkspace(); + }); + + test("Returns the implementation", async() => { + let implementationList = (await vscode.commands.executeCommand("vscode.executeImplementationProvider", fileUri, new vscode.Position(4, 22))); + expect(implementationList.length).to.be.equal(2); + }); +}); \ No newline at end of file diff --git a/test/integrationTests/testAssets/singleCsproj/implementation.cs b/test/integrationTests/testAssets/singleCsproj/implementation.cs new file mode 100644 index 000000000..abddb3511 --- /dev/null +++ b/test/integrationTests/testAssets/singleCsproj/implementation.cs @@ -0,0 +1,7 @@ +using System; + +namespace minimal +{ + public class BaseClass {} + public class SomeClass : BaseClass {} +} \ No newline at end of file diff --git a/test/integrationTests/testAssets/slnWithCsproj/src/app/implementation.cs b/test/integrationTests/testAssets/slnWithCsproj/src/app/implementation.cs new file mode 100644 index 000000000..abddb3511 --- /dev/null +++ b/test/integrationTests/testAssets/slnWithCsproj/src/app/implementation.cs @@ -0,0 +1,7 @@ +using System; + +namespace minimal +{ + public class BaseClass {} + public class SomeClass : BaseClass {} +} \ No newline at end of file From 98b6afc3c1e3ff60b5188923ac64a855eb8ce2ed Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Thu, 12 Jul 2018 16:52:56 -0700 Subject: [PATCH 2/2] Use the integration helpers --- .../implementationProvider.test.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test/integrationTests/implementationProvider.test.ts b/test/integrationTests/implementationProvider.test.ts index 15db8d0b9..d7074d983 100644 --- a/test/integrationTests/implementationProvider.test.ts +++ b/test/integrationTests/implementationProvider.test.ts @@ -5,24 +5,21 @@ import * as vscode from "vscode"; import CSharpImplementationProvider from "../../src/features/implementationProvider"; -import CSharpExtensionExports from "../../src/CSharpExtensionExports"; import * as path from "path"; import testAssetWorkspace from "./testAssets/testAssetWorkspace"; import { expect } from "chai"; +import { activateCSharpExtension } from './integrationHelpers'; suite(`${CSharpImplementationProvider.name}: ${testAssetWorkspace.description}`, () => { let fileUri: vscode.Uri; - + suiteSetup(async () => { - let csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp"); - if (!csharpExtension.isActive) { - await csharpExtension.activate(); - } + await testAssetWorkspace.restore(); + await activateCSharpExtension(); - await csharpExtension.exports.initializationFinished(); let fileName = 'implementation.cs'; - let dir = path.dirname(testAssetWorkspace.projects[0].projectDirectoryPath); - fileUri = vscode.Uri.file(path.join(dir, fileName)); + let projectDirectory = testAssetWorkspace.projects[0].projectDirectoryPath; + fileUri = vscode.Uri.file(path.join(projectDirectory, fileName)); await vscode.commands.executeCommand("vscode.open", fileUri); });