mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
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
This commit is contained in:
@@ -35,7 +35,6 @@ export interface IAccountManagementService {
|
|||||||
|
|
||||||
// SERVICE MANAGEMENT METHODS /////////////////////////////////////////
|
// SERVICE MANAGEMENT METHODS /////////////////////////////////////////
|
||||||
registerProvider(providerMetadata: azdata.AccountProviderMetadata, provider: azdata.AccountProvider): void;
|
registerProvider(providerMetadata: azdata.AccountProviderMetadata, provider: azdata.AccountProvider): void;
|
||||||
shutdown(): void;
|
|
||||||
unregisterProvider(providerMetadata: azdata.AccountProviderMetadata): void;
|
unregisterProvider(providerMetadata: azdata.AccountProviderMetadata): void;
|
||||||
|
|
||||||
// EVENTING ////////////////////////////////////////////////////////////
|
// EVENTING ////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
|||||||
this.cleanupProviders();
|
this.cleanupProviders();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_storageService.onWillSaveState(() => this.shutdown());
|
||||||
|
|
||||||
this._register(extentionManagementService.onDidUninstallExtension(({ identifier }) => {
|
this._register(extentionManagementService.onDidUninstallExtension(({ identifier }) => {
|
||||||
const connectionProvider = 'connectionProvider';
|
const connectionProvider = 'connectionProvider';
|
||||||
let extensionid = getIdFromLocalExtensionId(identifier.id);
|
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();
|
this._momento.saveMemento();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
|||||||
this.onConnectionChanged(() => this.refreshEditorTitles());
|
this.onConnectionChanged(() => this.refreshEditorTitles());
|
||||||
this.onConnect(() => this.refreshEditorTitles());
|
this.onConnect(() => this.refreshEditorTitles());
|
||||||
this.onDisconnect(() => this.refreshEditorTitles());
|
this.onDisconnect(() => this.refreshEditorTitles());
|
||||||
|
_storageService.onWillSaveState(() => this.shutdown());
|
||||||
}
|
}
|
||||||
|
|
||||||
public providerRegistered(providerId: string): boolean {
|
public providerRegistered(providerId: string): boolean {
|
||||||
@@ -936,7 +937,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
|||||||
public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
|
public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
public shutdown(): void {
|
private shutdown(): void {
|
||||||
this._connectionStore.clearActiveConnections();
|
this._connectionStore.clearActiveConnections();
|
||||||
this._connectionMemento.saveMemento();
|
this._connectionMemento.saveMemento();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class AccountManagementService implements IAccountManagementService {
|
|||||||
private _mementoObj: object,
|
private _mementoObj: object,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IStorageService private _storageService: IStorageService,
|
@IStorageService private _storageService: IStorageService,
|
||||||
@IClipboardService private _clipboardService: IClipboardService,
|
@IClipboardService private _clipboardService: IClipboardService
|
||||||
) {
|
) {
|
||||||
// Create the account store
|
// Create the account store
|
||||||
if (!this._mementoObj) {
|
if (!this._mementoObj) {
|
||||||
@@ -65,6 +65,8 @@ export class AccountManagementService implements IAccountManagementService {
|
|||||||
this._removeAccountProviderEmitter = new Emitter<azdata.AccountProviderMetadata>();
|
this._removeAccountProviderEmitter = new Emitter<azdata.AccountProviderMetadata>();
|
||||||
this._updateAccountListEmitter = new Emitter<UpdateAccountListEventParams>();
|
this._updateAccountListEmitter = new Emitter<UpdateAccountListEventParams>();
|
||||||
|
|
||||||
|
_storageService.onWillSaveState(() => this.shutdown());
|
||||||
|
|
||||||
// Register status bar item
|
// Register status bar item
|
||||||
let statusbarDescriptor = new statusbar.StatusbarItemDescriptor(
|
let statusbarDescriptor = new statusbar.StatusbarItemDescriptor(
|
||||||
AccountListStatusbarItem,
|
AccountListStatusbarItem,
|
||||||
@@ -367,7 +369,7 @@ export class AccountManagementService implements IAccountManagementService {
|
|||||||
/**
|
/**
|
||||||
* Handler for when shutdown of the application occurs. Writes out the memento.
|
* Handler for when shutdown of the application occurs. Writes out the memento.
|
||||||
*/
|
*/
|
||||||
public shutdown(): void {
|
private shutdown(): void {
|
||||||
if (this._mementoContext) {
|
if (this._mementoContext) {
|
||||||
this._mementoContext.saveMemento();
|
this._mementoContext.saveMemento();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ export interface INotebookService {
|
|||||||
|
|
||||||
listNotebookEditors(): INotebookEditor[];
|
listNotebookEditors(): INotebookEditor[];
|
||||||
|
|
||||||
shutdown(): void;
|
|
||||||
|
|
||||||
getMimeRegistry(): RenderMimeRegistry;
|
getMimeRegistry(): RenderMimeRegistry;
|
||||||
|
|
||||||
renameNotebookEditor(oldUri: URI, newUri: URI, currentEditor: INotebookEditor): void;
|
renameNotebookEditor(oldUri: URI, newUri: URI, currentEditor: INotebookEditor): void;
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
|
|||||||
import { NotebookEditor } from 'sql/parts/notebook/notebookEditor';
|
import { NotebookEditor } from 'sql/parts/notebook/notebookEditor';
|
||||||
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
|
||||||
import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles';
|
import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles';
|
||||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||||
import { ILanguageMagic, notebookConstants } from 'sql/parts/notebook/models/modelInterfaces';
|
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';
|
import { SqlNotebookProvider } from 'sql/workbench/services/notebook/sql/sqlNotebookProvider';
|
||||||
|
|
||||||
export interface NotebookProviderProperties {
|
export interface NotebookProviderProperties {
|
||||||
@@ -95,6 +95,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
private _overrideEditorThemeSetting: boolean;
|
private _overrideEditorThemeSetting: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ILifecycleService lifecycleService: ILifecycleService,
|
||||||
@IStorageService private _storageService: IStorageService,
|
@IStorageService private _storageService: IStorageService,
|
||||||
@IExtensionService extensionService: IExtensionService,
|
@IExtensionService extensionService: IExtensionService,
|
||||||
@IExtensionManagementService extensionManagementService: IExtensionManagementService,
|
@IExtensionManagementService extensionManagementService: IExtensionManagementService,
|
||||||
@@ -103,7 +104,6 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
@IEditorService private readonly _editorService: IEditorService,
|
@IEditorService private readonly _editorService: IEditorService,
|
||||||
@IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService,
|
@IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService,
|
||||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||||
@IThemeService private readonly _themeService: IThemeService,
|
|
||||||
@IQueryManagementService private readonly _queryManagementService
|
@IQueryManagementService private readonly _queryManagementService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
@@ -128,6 +128,8 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
if (extensionManagementService) {
|
if (extensionManagementService) {
|
||||||
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => this.removeContributedProvidersFromCache(identifier, extensionService)));
|
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => this.removeContributedProvidersFromCache(identifier, extensionService)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lifecycleService.onWillShutdown(() => this.shutdown());
|
||||||
this.hookContextKeyListeners();
|
this.hookContextKeyListeners();
|
||||||
this.hookNotebookThemesAndConfigListener();
|
this.hookNotebookThemesAndConfigListener();
|
||||||
}
|
}
|
||||||
@@ -284,7 +286,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
return this._providerToStandardKernels.get(provider.toUpperCase());
|
return this._providerToStandardKernels.get(provider.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public shutdown(): void {
|
private shutdown(): void {
|
||||||
this._managersMap.forEach(manager => {
|
this._managersMap.forEach(manager => {
|
||||||
manager.forEach(m => {
|
manager.forEach(m => {
|
||||||
if (m.serverManager) {
|
if (m.serverManager) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub';
|
|||||||
import { ErrorMessageServiceStub } from 'sqltest/stubs/errorMessageServiceStub';
|
import { ErrorMessageServiceStub } from 'sqltest/stubs/errorMessageServiceStub';
|
||||||
|
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
suite('ConnectionDialogService tests', () => {
|
suite('ConnectionDialogService tests', () => {
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
let errorMessageService = getMockErrorMessageService();
|
let errorMessageService = getMockErrorMessageService();
|
||||||
connectionDialogService = new ConnectionDialogService(undefined, undefined, undefined, errorMessageService.object,
|
connectionDialogService = new ConnectionDialogService(undefined, undefined, undefined, errorMessageService.object,
|
||||||
undefined, undefined, undefined);
|
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;
|
(connectionDialogService as any)._connectionManagementService = mockConnectionManagementService.object;
|
||||||
mockConnectionDialog = TypeMoq.Mock.ofType(ConnectionDialogWidget, TypeMoq.MockBehavior.Strict,
|
mockConnectionDialog = TypeMoq.Mock.ofType(ConnectionDialogWidget, TypeMoq.MockBehavior.Strict,
|
||||||
undefined,
|
undefined,
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import * as TypeMoq from 'typemoq';
|
|||||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
||||||
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
suite('SQL ConnectionManagementService tests', () => {
|
suite('SQL ConnectionManagementService tests', () => {
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
let connectionManagementService = new ConnectionManagementService(
|
let connectionManagementService = new ConnectionManagementService(
|
||||||
undefined,
|
undefined,
|
||||||
connectionStore.object,
|
connectionStore.object,
|
||||||
undefined,
|
new TestStorageService(),
|
||||||
connectionDialogService.object,
|
connectionDialogService.object,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { IDbColumn, BatchSummary, QueryExecuteSubsetResult, ResultSetSubset } fr
|
|||||||
import { EventEmitter } from 'sql/base/common/eventEmitter';
|
import { EventEmitter } from 'sql/base/common/eventEmitter';
|
||||||
import { equal } from 'assert';
|
import { equal } from 'assert';
|
||||||
import { Mock, MockBehavior, It } from 'typemoq';
|
import { Mock, MockBehavior, It } from 'typemoq';
|
||||||
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
const testData: string[][] = [
|
const testData: string[][] = [
|
||||||
['1', '2', '3', '4'],
|
['1', '2', '3', '4'],
|
||||||
@@ -38,7 +39,7 @@ suite('Insights Dialog Controller Tests', () => {
|
|||||||
instMoq.setup(x => x.createInstance(It.isValue(QueryRunner), It.isAny()))
|
instMoq.setup(x => x.createInstance(It.isValue(QueryRunner), It.isAny()))
|
||||||
.returns(() => runner);
|
.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()))
|
connMoq.setup(x => x.connect(It.isAny(), It.isAny()))
|
||||||
.returns(() => Promise.resolve(undefined));
|
.returns(() => Promise.resolve(undefined));
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { Memento } from 'vs/workbench/common/memento';
|
|||||||
import { Emitter } from 'vs/base/common/event';
|
import { Emitter } from 'vs/base/common/event';
|
||||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
let expectedNotebookContent: nb.INotebookContents = {
|
let expectedNotebookContent: nb.INotebookContents = {
|
||||||
cells: [{
|
cells: [{
|
||||||
@@ -86,7 +87,7 @@ suite('notebook model', function (): void {
|
|||||||
capabilitiesService = TypeMoq.Mock.ofType(CapabilitiesTestService);
|
capabilitiesService = TypeMoq.Mock.ofType(CapabilitiesTestService);
|
||||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
|
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.callBase = true;
|
||||||
defaultModelOptions = {
|
defaultModelOptions = {
|
||||||
notebookUri: defaultUri,
|
notebookUri: defaultUri,
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
let isConnectedReturnValue: boolean = false;
|
let isConnectedReturnValue: boolean = false;
|
||||||
|
|
||||||
// ... Mock "isConnected in ConnectionManagementService
|
// ... 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);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnectedReturnValue);
|
||||||
|
|
||||||
// ... Create an editor
|
// ... Create an editor
|
||||||
@@ -125,7 +125,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
.returns(() => TPromise.as(none));
|
.returns(() => TPromise.as(none));
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
queryEditor.setup(x => x.isSelectionEmpty()).returns(() => isSelectionEmpty);
|
queryEditor.setup(x => x.isSelectionEmpty()).returns(() => isSelectionEmpty);
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => true);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => true);
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
let calledCancelQuery: boolean = false;
|
let calledCancelQuery: boolean = false;
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
|
|
||||||
// ... Mock QueryModelService
|
// ... Mock QueryModelService
|
||||||
@@ -349,7 +349,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
let countCalledDisconnectEditor: number = 0;
|
let countCalledDisconnectEditor: number = 0;
|
||||||
|
|
||||||
// ... Mock "isConnected" and "disconnectEditor" in ConnectionManagementService
|
// ... 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.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
connectionManagementService.setup(x => x.disconnectEditor(TypeMoq.It.isAny())).callback(() => {
|
connectionManagementService.setup(x => x.disconnectEditor(TypeMoq.It.isAny())).callback(() => {
|
||||||
countCalledDisconnectEditor++;
|
countCalledDisconnectEditor++;
|
||||||
@@ -388,7 +388,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
.returns(() => TPromise.as(none));
|
.returns(() => TPromise.as(none));
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
.returns(() => TPromise.as(none));
|
.returns(() => TPromise.as(none));
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
let databaseName: string = undefined;
|
let databaseName: string = undefined;
|
||||||
|
|
||||||
// ... Mock "isConnected" in ConnectionManagementService
|
// ... 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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||||
connectionManagementService.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{
|
connectionManagementService.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{
|
||||||
@@ -506,7 +506,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
|
|
||||||
// ... Create mock connection management service
|
// ... Create mock connection management service
|
||||||
let databaseName = 'foobar';
|
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.callBase = true;
|
||||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||||
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||||
@@ -530,7 +530,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
|
|
||||||
// ... Create mock connection management service that will not claim it's connected
|
// ... Create mock connection management service that will not claim it's connected
|
||||||
let databaseName = 'foobar';
|
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.callBase = true;
|
||||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||||
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||||
@@ -558,7 +558,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
let dbChangedEmitter = new Emitter<IConnectionParams>();
|
let dbChangedEmitter = new Emitter<IConnectionParams>();
|
||||||
|
|
||||||
// ... Create mock connection management service
|
// ... 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.callBase = true;
|
||||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
// Mock ConnectionManagementService
|
// Mock ConnectionManagementService
|
||||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
|
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.callBase = true;
|
||||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAny())).returns(() => false);
|
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAny())).returns(() => false);
|
||||||
connectionManagementService.setup(x => x.disconnectEditor(TypeMoq.It.isAny())).returns(() => void 0);
|
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
|
// Mock ConnectionManagementService but don't set connected state
|
||||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
|
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.callBase = true;
|
||||||
|
|
||||||
queryConnectionService.setup(x => x.disconnectEditor(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
|
queryConnectionService.setup(x => x.disconnectEditor(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => void 0);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { ConnectionManagementService } from 'sql/platform/connection/common/conn
|
|||||||
|
|
||||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||||
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
let instantiationService = new TestInstantiationService();
|
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 => []);
|
mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []);
|
||||||
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined);
|
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined);
|
||||||
let tree = <Tree>{
|
let tree = <Tree>{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { IAccountStore } from 'sql/platform/accountManagement/common/interfaces'
|
|||||||
import { AccountProviderStub } from 'sqltest/stubs/accountManagementStubs';
|
import { AccountProviderStub } from 'sqltest/stubs/accountManagementStubs';
|
||||||
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
||||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||||
|
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
// SUITE CONSTANTS /////////////////////////////////////////////////////////
|
// SUITE CONSTANTS /////////////////////////////////////////////////////////
|
||||||
const hasAccountProvider: azdata.AccountProviderMetadata = {
|
const hasAccountProvider: azdata.AccountProviderMetadata = {
|
||||||
@@ -566,7 +567,7 @@ function getTestState(): AccountManagementState {
|
|||||||
let mockMemento = {};
|
let mockMemento = {};
|
||||||
|
|
||||||
// Create the account management service
|
// 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
|
// Wire up event handlers
|
||||||
let evUpdate = new EventVerifierSingle<UpdateAccountListEventParams>();
|
let evUpdate = new EventVerifierSingle<UpdateAccountListEventParams>();
|
||||||
|
|||||||
@@ -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 { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
||||||
import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub';
|
import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub';
|
||||||
|
import { TestLifecycleService } from 'vs/workbench/test/workbenchTestServices';
|
||||||
|
|
||||||
suite('MainThreadNotebook Tests', () => {
|
suite('MainThreadNotebook Tests', () => {
|
||||||
|
|
||||||
@@ -27,12 +28,13 @@ suite('MainThreadNotebook Tests', () => {
|
|||||||
let notebookUri: URI;
|
let notebookUri: URI;
|
||||||
let mockNotebookService: TypeMoq.Mock<NotebookService>;
|
let mockNotebookService: TypeMoq.Mock<NotebookService>;
|
||||||
let providerId = 'TestProvider';
|
let providerId = 'TestProvider';
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
mockProxy = TypeMoq.Mock.ofType(ExtHostNotebookStub);
|
mockProxy = TypeMoq.Mock.ofType(ExtHostNotebookStub);
|
||||||
let extContext = <IExtHostContext>{
|
let extContext = <IExtHostContext>{
|
||||||
getProxy: proxyType => mockProxy.object
|
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');
|
notebookUri = URI.parse('file:/user/default/my.ipynb');
|
||||||
mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object);
|
mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -585,10 +585,6 @@ export class Workbench extends Disposable implements IPartService {
|
|||||||
serviceCollection.set(ICommandLineProcessing, this.instantiationService.createInstance(CommandLineService));
|
serviceCollection.set(ICommandLineProcessing, this.instantiationService.createInstance(CommandLineService));
|
||||||
serviceCollection.set(IDacFxService, this.instantiationService.createInstance(DacFxService));
|
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
|
// {{SQL CARBON EDIT}} - End
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user