Swapping vscode calls for ApiWrapper for testability (#10267)

* swapping vscode calls for apiwrapper for testability

* Adding mainController tests

* Adding unit tests for input validation

* Adding project controller tests, reorganizing error handling

* Removing commented-out code
This commit is contained in:
Benjin Dubishar
2020-05-06 14:16:27 -07:00
committed by GitHub
parent 0ace033a6f
commit 80901c9a7b
10 changed files with 373 additions and 108 deletions

View File

@@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as path from 'path';
import * as TypeMoq from 'typemoq';
import { ApiWrapper } from '../common/apiWrapper';
export interface TestContext {
apiWrapper: TypeMoq.IMock<ApiWrapper>;
context: vscode.ExtensionContext;
}
export function createContext(): TestContext {
let extensionPath = path.join(__dirname, '..', '..');
return {
apiWrapper: TypeMoq.Mock.ofType(ApiWrapper),
context: {
subscriptions: [],
workspaceState: {
get: () => { return undefined; },
update: () => { return Promise.resolve(); }
},
globalState: {
get: () => { return Promise.resolve(); },
update: () => { return Promise.resolve(); }
},
extensionPath: extensionPath,
asAbsolutePath: () => { return ''; },
storagePath: '',
globalStoragePath: '',
logPath: '',
extensionUri: vscode.Uri.parse('')
},
};
}