From b6584c9ddfd688b16d799e7afeb51deee8ba619d Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Wed, 13 Mar 2019 15:15:51 -0700 Subject: [PATCH] Change shutdown listeners (#4282) * change shutdown to use proper notification * change to use storage service * remove unused imports * fix test * change shutdown methods to private * remove unusde imports * fix tests * formatting --- .../accountManagement/common/interfaces.ts | 1 - .../common/capabilitiesService.ts | 4 ++- .../common/connectionManagementService.ts | 3 +- .../browser/accountManagementService.ts | 6 ++-- .../notebook/common/notebookService.ts | 4 +-- .../notebook/common/notebookServiceImpl.ts | 10 ++++--- .../connectionDialogService.test.ts | 5 ++-- .../connectionManagementService.test.ts | 5 ++-- .../insights/insightsDialogController.test.ts | 3 +- .../notebook/model/notebookModel.test.ts | 3 +- .../parts/query/editor/queryActions.test.ts | 28 +++++++++---------- .../parts/query/editor/queryEditor.test.ts | 6 ++-- .../viewlet/serverTreeView.test.ts | 5 ++-- .../accountManagementService.test.ts | 3 +- .../workbench/api/mainThreadNotebook.test.ts | 4 ++- .../workbench/electron-browser/workbench.ts | 4 --- 16 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/sql/platform/accountManagement/common/interfaces.ts b/src/sql/platform/accountManagement/common/interfaces.ts index 766770dd27..195d2a0983 100644 --- a/src/sql/platform/accountManagement/common/interfaces.ts +++ b/src/sql/platform/accountManagement/common/interfaces.ts @@ -35,7 +35,6 @@ export interface IAccountManagementService { // SERVICE MANAGEMENT METHODS ///////////////////////////////////////// registerProvider(providerMetadata: azdata.AccountProviderMetadata, provider: azdata.AccountProvider): void; - shutdown(): void; unregisterProvider(providerMetadata: azdata.AccountProviderMetadata): void; // EVENTING //////////////////////////////////////////////////////////// diff --git a/src/sql/platform/capabilities/common/capabilitiesService.ts b/src/sql/platform/capabilities/common/capabilitiesService.ts index 057f1b0692..6b25f9baae 100644 --- a/src/sql/platform/capabilities/common/capabilitiesService.ts +++ b/src/sql/platform/capabilities/common/capabilitiesService.ts @@ -131,6 +131,8 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ this.cleanupProviders(); }); + _storageService.onWillSaveState(() => this.shutdown()); + this._register(extentionManagementService.onDidUninstallExtension(({ identifier }) => { const connectionProvider = 'connectionProvider'; let extensionid = getIdFromLocalExtensionId(identifier.id); @@ -239,7 +241,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ } } - public shutdown(): void { + private shutdown(): void { this._momento.saveMemento(); } } diff --git a/src/sql/platform/connection/common/connectionManagementService.ts b/src/sql/platform/connection/common/connectionManagementService.ts index 18376b86da..aeb93b83bf 100644 --- a/src/sql/platform/connection/common/connectionManagementService.ts +++ b/src/sql/platform/connection/common/connectionManagementService.ts @@ -141,6 +141,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti this.onConnectionChanged(() => this.refreshEditorTitles()); this.onConnect(() => this.refreshEditorTitles()); this.onDisconnect(() => this.refreshEditorTitles()); + _storageService.onWillSaveState(() => this.shutdown()); } public providerRegistered(providerId: string): boolean { @@ -936,7 +937,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void { } - public shutdown(): void { + private shutdown(): void { this._connectionStore.clearActiveConnections(); this._connectionMemento.saveMemento(); } diff --git a/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts b/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts index 636ecf3b66..f2a9769e6c 100644 --- a/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts +++ b/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts @@ -51,7 +51,7 @@ export class AccountManagementService implements IAccountManagementService { private _mementoObj: object, @IInstantiationService private _instantiationService: IInstantiationService, @IStorageService private _storageService: IStorageService, - @IClipboardService private _clipboardService: IClipboardService, + @IClipboardService private _clipboardService: IClipboardService ) { // Create the account store if (!this._mementoObj) { @@ -65,6 +65,8 @@ export class AccountManagementService implements IAccountManagementService { this._removeAccountProviderEmitter = new Emitter(); this._updateAccountListEmitter = new Emitter(); + _storageService.onWillSaveState(() => this.shutdown()); + // Register status bar item let statusbarDescriptor = new statusbar.StatusbarItemDescriptor( AccountListStatusbarItem, @@ -367,7 +369,7 @@ export class AccountManagementService implements IAccountManagementService { /** * Handler for when shutdown of the application occurs. Writes out the memento. */ - public shutdown(): void { + private shutdown(): void { if (this._mementoContext) { this._mementoContext.saveMemento(); } diff --git a/src/sql/workbench/services/notebook/common/notebookService.ts b/src/sql/workbench/services/notebook/common/notebookService.ts index 7daf5a9fb5..1ccb4ee099 100644 --- a/src/sql/workbench/services/notebook/common/notebookService.ts +++ b/src/sql/workbench/services/notebook/common/notebookService.ts @@ -67,8 +67,6 @@ export interface INotebookService { listNotebookEditors(): INotebookEditor[]; - shutdown(): void; - getMimeRegistry(): RenderMimeRegistry; renameNotebookEditor(oldUri: URI, newUri: URI, currentEditor: INotebookEditor): void; @@ -108,4 +106,4 @@ export interface INotebookEditor { isVisible(): boolean; executeEdits(edits: ISingleNotebookEditOperation[]): boolean; runCell(cell: ICellModel): Promise; -} \ No newline at end of file +} diff --git a/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts b/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts index 09176a4eec..152713ffb4 100644 --- a/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts +++ b/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts @@ -32,10 +32,10 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { NotebookEditor } from 'sql/parts/notebook/notebookEditor'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IThemeService } from 'vs/platform/theme/common/themeService'; import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles'; import { IQueryManagementService } from 'sql/platform/query/common/queryManagement'; import { ILanguageMagic, notebookConstants } from 'sql/parts/notebook/models/modelInterfaces'; +import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { SqlNotebookProvider } from 'sql/workbench/services/notebook/sql/sqlNotebookProvider'; export interface NotebookProviderProperties { @@ -95,6 +95,7 @@ export class NotebookService extends Disposable implements INotebookService { private _overrideEditorThemeSetting: boolean; constructor( + @ILifecycleService lifecycleService: ILifecycleService, @IStorageService private _storageService: IStorageService, @IExtensionService extensionService: IExtensionService, @IExtensionManagementService extensionManagementService: IExtensionManagementService, @@ -103,7 +104,6 @@ export class NotebookService extends Disposable implements INotebookService { @IEditorService private readonly _editorService: IEditorService, @IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService, @IConfigurationService private readonly _configurationService: IConfigurationService, - @IThemeService private readonly _themeService: IThemeService, @IQueryManagementService private readonly _queryManagementService ) { super(); @@ -128,6 +128,8 @@ export class NotebookService extends Disposable implements INotebookService { if (extensionManagementService) { this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => this.removeContributedProvidersFromCache(identifier, extensionService))); } + + lifecycleService.onWillShutdown(() => this.shutdown()); this.hookContextKeyListeners(); this.hookNotebookThemesAndConfigListener(); } @@ -284,7 +286,7 @@ export class NotebookService extends Disposable implements INotebookService { return this._providerToStandardKernels.get(provider.toUpperCase()); } - public shutdown(): void { + private shutdown(): void { this._managersMap.forEach(manager => { manager.forEach(m => { if (m.serverManager) { @@ -469,4 +471,4 @@ export class NotebookService extends Disposable implements INotebookService { } }); } -} \ No newline at end of file +} diff --git a/src/sqltest/parts/connection/connectionDialogService.test.ts b/src/sqltest/parts/connection/connectionDialogService.test.ts index f39b2ab16e..29a1bdccf9 100644 --- a/src/sqltest/parts/connection/connectionDialogService.test.ts +++ b/src/sqltest/parts/connection/connectionDialogService.test.ts @@ -13,6 +13,7 @@ import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub'; import { ErrorMessageServiceStub } from 'sqltest/stubs/errorMessageServiceStub'; import * as TypeMoq from 'typemoq'; +import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; suite('ConnectionDialogService tests', () => { @@ -24,7 +25,7 @@ suite('ConnectionDialogService tests', () => { let errorMessageService = getMockErrorMessageService(); connectionDialogService = new ConnectionDialogService(undefined, undefined, undefined, errorMessageService.object, undefined, undefined, undefined); - mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}); + mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}, new TestStorageService()); (connectionDialogService as any)._connectionManagementService = mockConnectionManagementService.object; mockConnectionDialog = TypeMoq.Mock.ofType(ConnectionDialogWidget, TypeMoq.MockBehavior.Strict, undefined, @@ -87,4 +88,4 @@ suite('ConnectionDialogService tests', () => { done(err); }); }); -}); \ No newline at end of file +}); diff --git a/src/sqltest/parts/connection/connectionManagementService.test.ts b/src/sqltest/parts/connection/connectionManagementService.test.ts index bd2b8a0fe1..6ce45249b4 100644 --- a/src/sqltest/parts/connection/connectionManagementService.test.ts +++ b/src/sqltest/parts/connection/connectionManagementService.test.ts @@ -35,6 +35,7 @@ import * as TypeMoq from 'typemoq'; import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup'; import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs'; +import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; suite('SQL ConnectionManagementService tests', () => { @@ -149,7 +150,7 @@ suite('SQL ConnectionManagementService tests', () => { let connectionManagementService = new ConnectionManagementService( undefined, connectionStore.object, - undefined, + new TestStorageService(), connectionDialogService.object, undefined, undefined, @@ -919,4 +920,4 @@ suite('SQL ConnectionManagementService tests', () => { assert.equal(profileWithCredentials.userName, username); assert.equal(profileWithCredentials.options['azureAccountToken'], testToken); }); -}); \ No newline at end of file +}); diff --git a/src/sqltest/parts/insights/insightsDialogController.test.ts b/src/sqltest/parts/insights/insightsDialogController.test.ts index 1d1c2d2a92..858e62e499 100644 --- a/src/sqltest/parts/insights/insightsDialogController.test.ts +++ b/src/sqltest/parts/insights/insightsDialogController.test.ts @@ -16,6 +16,7 @@ import { IDbColumn, BatchSummary, QueryExecuteSubsetResult, ResultSetSubset } fr import { EventEmitter } from 'sql/base/common/eventEmitter'; import { equal } from 'assert'; import { Mock, MockBehavior, It } from 'typemoq'; +import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; const testData: string[][] = [ ['1', '2', '3', '4'], @@ -38,7 +39,7 @@ suite('Insights Dialog Controller Tests', () => { instMoq.setup(x => x.createInstance(It.isValue(QueryRunner), It.isAny())) .returns(() => runner); - let connMoq = Mock.ofType(ConnectionManagementService, MockBehavior.Strict, {}, {}); + let connMoq = Mock.ofType(ConnectionManagementService, MockBehavior.Strict, {}, {}, new TestStorageService()); connMoq.setup(x => x.connect(It.isAny(), It.isAny())) .returns(() => Promise.resolve(undefined)); diff --git a/src/sqltest/parts/notebook/model/notebookModel.test.ts b/src/sqltest/parts/notebook/model/notebookModel.test.ts index dcd44a54b4..8e1fe7b817 100644 --- a/src/sqltest/parts/notebook/model/notebookModel.test.ts +++ b/src/sqltest/parts/notebook/model/notebookModel.test.ts @@ -27,6 +27,7 @@ import { Memento } from 'vs/workbench/common/memento'; import { Emitter } from 'vs/base/common/event'; import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; +import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; let expectedNotebookContent: nb.INotebookContents = { cells: [{ @@ -86,7 +87,7 @@ suite('notebook model', function (): void { capabilitiesService = TypeMoq.Mock.ofType(CapabilitiesTestService); memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, ''); memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0); - queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined); + queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService()); queryConnectionService.callBase = true; defaultModelOptions = { notebookUri: defaultUri, diff --git a/src/sqltest/parts/query/editor/queryActions.test.ts b/src/sqltest/parts/query/editor/queryActions.test.ts index be9709b638..c838adb960 100644 --- a/src/sqltest/parts/query/editor/queryActions.test.ts +++ b/src/sqltest/parts/query/editor/queryActions.test.ts @@ -84,7 +84,7 @@ suite('SQL QueryAction Tests', () => { let isConnectedReturnValue: boolean = false; // ... Mock "isConnected in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnectedReturnValue); // ... Create an editor @@ -125,7 +125,7 @@ suite('SQL QueryAction Tests', () => { .returns(() => TPromise.as(none)); // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, undefined, connectionDialogService.object); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); @@ -176,14 +176,14 @@ suite('SQL QueryAction Tests', () => { countCalledRunQuery++; }); let queryEditor: TypeMoq.Mock = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService(), undefined, - undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService()); + undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService()); queryEditor.setup(x => x.currentQueryInput).returns(() => queryInput.object); queryEditor.setup(x => x.getSelection()).returns(() => undefined); queryEditor.setup(x => x.getSelection(false)).returns(() => undefined); queryEditor.setup(x => x.isSelectionEmpty()).returns(() => isSelectionEmpty); // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => true); @@ -243,14 +243,14 @@ suite('SQL QueryAction Tests', () => { // ... Mock "getSelection" in QueryEditor let queryEditor: TypeMoq.Mock = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService(), undefined, - undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService()); + undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService()); queryEditor.setup(x => x.currentQueryInput).returns(() => queryInput.object); queryEditor.setup(x => x.getSelection()).returns(() => { return selectionToReturnInGetSelection; }); // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, undefined, connectionDialogService.object); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); @@ -316,7 +316,7 @@ suite('SQL QueryAction Tests', () => { let calledCancelQuery: boolean = false; // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); // ... Mock QueryModelService @@ -349,7 +349,7 @@ suite('SQL QueryAction Tests', () => { let countCalledDisconnectEditor: number = 0; // ... Mock "isConnected" and "disconnectEditor" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); connectionManagementService.setup(x => x.disconnectEditor(TypeMoq.It.isAny())).callback(() => { countCalledDisconnectEditor++; @@ -388,7 +388,7 @@ suite('SQL QueryAction Tests', () => { .returns(() => TPromise.as(none)); // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, undefined, connectionDialogService.object); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); @@ -434,7 +434,7 @@ suite('SQL QueryAction Tests', () => { .returns(() => TPromise.as(none)); // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, undefined, connectionDialogService.object); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService(), connectionDialogService.object); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); @@ -469,7 +469,7 @@ suite('SQL QueryAction Tests', () => { let databaseName: string = undefined; // ... Mock "isConnected" in ConnectionManagementService - let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected); connectionManagementService.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => { @@ -506,7 +506,7 @@ suite('SQL QueryAction Tests', () => { // ... Create mock connection management service let databaseName = 'foobar'; - let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); cms.callBase = true; cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event); cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => { databaseName: databaseName }); @@ -530,7 +530,7 @@ suite('SQL QueryAction Tests', () => { // ... Create mock connection management service that will not claim it's connected let databaseName = 'foobar'; - let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); cms.callBase = true; cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event); cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => { databaseName: databaseName }); @@ -558,7 +558,7 @@ suite('SQL QueryAction Tests', () => { let dbChangedEmitter = new Emitter(); // ... Create mock connection management service - let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}); + let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService()); cms.callBase = true; cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event); diff --git a/src/sqltest/parts/query/editor/queryEditor.test.ts b/src/sqltest/parts/query/editor/queryEditor.test.ts index 46e69012cb..2452630ca8 100644 --- a/src/sqltest/parts/query/editor/queryEditor.test.ts +++ b/src/sqltest/parts/query/editor/queryEditor.test.ts @@ -140,7 +140,7 @@ suite('SQL QueryEditor Tests', () => { // Mock ConnectionManagementService memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, ''); memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0); - connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined); + connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService()); connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAny())).returns(() => false); connectionManagementService.setup(x => x.disconnectEditor(TypeMoq.It.isAny())).returns(() => void 0); @@ -329,7 +329,7 @@ suite('SQL QueryEditor Tests', () => { // Mock ConnectionManagementService but don't set connected state memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, ''); memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0); - queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined); + queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService()); queryConnectionService.callBase = true; queryConnectionService.setup(x => x.disconnectEditor(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0); @@ -408,4 +408,4 @@ suite('SQL QueryEditor Tests', () => { done(); }); }); -}); \ No newline at end of file +}); diff --git a/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts b/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts index 47a83d683c..b24c927e3d 100644 --- a/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts +++ b/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts @@ -11,6 +11,7 @@ import { ConnectionManagementService } from 'sql/platform/connection/common/conn import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; +import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; import * as TypeMoq from 'typemoq'; @@ -22,7 +23,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => { setup(() => { let instantiationService = new TestInstantiationService(); - let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}); + let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}, new TestStorageService()); mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []); serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined); let tree = { @@ -90,4 +91,4 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => { mockTree.verify(x => x.clearSelection(), TypeMoq.Times.never()); mockTree.verify(x => x.select(TypeMoq.It.isAny()), TypeMoq.Times.never()); }); -}); \ No newline at end of file +}); diff --git a/src/sqltest/services/accountManagement/accountManagementService.test.ts b/src/sqltest/services/accountManagement/accountManagementService.test.ts index 1a8d0bb4f7..cfa2026991 100644 --- a/src/sqltest/services/accountManagement/accountManagementService.test.ts +++ b/src/sqltest/services/accountManagement/accountManagementService.test.ts @@ -16,6 +16,7 @@ import { IAccountStore } from 'sql/platform/accountManagement/common/interfaces' import { AccountProviderStub } from 'sqltest/stubs/accountManagementStubs'; import { EventVerifierSingle } from 'sqltest/utils/eventVerifier'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; +import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; // SUITE CONSTANTS ///////////////////////////////////////////////////////// const hasAccountProvider: azdata.AccountProviderMetadata = { @@ -566,7 +567,7 @@ function getTestState(): AccountManagementState { let mockMemento = {}; // Create the account management service - let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, null, null); + let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, new TestStorageService(), null); // Wire up event handlers let evUpdate = new EventVerifierSingle(); diff --git a/src/sqltest/workbench/api/mainThreadNotebook.test.ts b/src/sqltest/workbench/api/mainThreadNotebook.test.ts index 3d1b861d32..5b10baf479 100644 --- a/src/sqltest/workbench/api/mainThreadNotebook.test.ts +++ b/src/sqltest/workbench/api/mainThreadNotebook.test.ts @@ -19,6 +19,7 @@ import { INotebookProvider } from 'sql/workbench/services/notebook/common/notebo import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes'; import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager'; import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub'; +import { TestLifecycleService } from 'vs/workbench/test/workbenchTestServices'; suite('MainThreadNotebook Tests', () => { @@ -27,12 +28,13 @@ suite('MainThreadNotebook Tests', () => { let notebookUri: URI; let mockNotebookService: TypeMoq.Mock; let providerId = 'TestProvider'; + setup(() => { mockProxy = TypeMoq.Mock.ofType(ExtHostNotebookStub); let extContext = { getProxy: proxyType => mockProxy.object }; - mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, undefined, undefined, undefined, undefined, new ContextKeyServiceStub()); + mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, undefined, new ContextKeyServiceStub()); notebookUri = URI.parse('file:/user/default/my.ipynb'); mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object); }); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index bdb68685a8..b474434a9f 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -585,10 +585,6 @@ export class Workbench extends Disposable implements IPartService { serviceCollection.set(ICommandLineProcessing, this.instantiationService.createInstance(CommandLineService)); serviceCollection.set(IDacFxService, this.instantiationService.createInstance(DacFxService)); - this._register(toDisposable(() => connectionManagementService.shutdown())); - this._register(toDisposable(() => accountManagementService.shutdown())); - this._register(toDisposable(() => notebookService.shutdown())); - this._register(toDisposable(() => capabilitiesService.shutdown())); // {{SQL CARBON EDIT}} - End }