mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 09:35:37 -05:00
Rework how we handle custom editors (#5696)
* update how we handle editors * small edit * handle changing languages * implement generic language association * implement notebook serializers * fix tests * formatting * update how we handle editors * small edit * handle changing languages * implement generic language association * implement notebook serializers * fix tests * formatting * fix broken * fix compile * fix tests * add back in removed note book contributions * fix layering * fix compile errors * fix workbench * fix hanging promises * idk why these changed * fix change * add comments to language change code * fix a few bugs * add query plan association
This commit is contained in:
@@ -3,50 +3,48 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
|
||||
import { ISelectionData } from 'azdata';
|
||||
|
||||
import {
|
||||
IConnectionManagementService,
|
||||
IConnectionParams,
|
||||
INewConnectionParams,
|
||||
ConnectionType,
|
||||
RunQueryOnConnectionMode
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionDialogService } from 'sql/workbench/services/connection/browser/connectionDialogService';
|
||||
import {
|
||||
RunQueryAction, CancelQueryAction, ListDatabasesActionItem,
|
||||
DisconnectDatabaseAction, ConnectDatabaseAction, QueryTaskbarAction
|
||||
} from 'sql/workbench/contrib/query/browser/queryActions';
|
||||
import { QueryInput } from 'sql/workbench/contrib/query/common/queryInput';
|
||||
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
||||
import { QueryModelService } from 'sql/platform/query/common/queryModelService';
|
||||
import { ConnectionManagementService } from 'sql/workbench/services/connection/browser/connectionManagementService';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
import { TestStorageService, TestFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
let none: void;
|
||||
import { TestQueryModelService } from 'sql/platform/query/test/common/testQueryModelService';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
|
||||
suite('SQL QueryAction Tests', () => {
|
||||
|
||||
let testUri: string = 'testURI';
|
||||
let editor: TypeMoq.Mock<QueryEditor>;
|
||||
let calledRunQueryOnInput: boolean = undefined;
|
||||
let testQueryInput: TypeMoq.Mock<QueryInput>;
|
||||
let configurationService: TypeMoq.Mock<IConfigurationService>;
|
||||
let testQueryInput: TypeMoq.Mock<UntitledQueryEditorInput>;
|
||||
let configurationService: TypeMoq.Mock<TestConfigurationService>;
|
||||
let queryModelService: TypeMoq.Mock<TestQueryModelService>;
|
||||
let connectionManagementService: TypeMoq.Mock<TestConnectionManagementService>;
|
||||
|
||||
setup(() => {
|
||||
// Setup a reusable mock QueryInput
|
||||
testQueryInput = TypeMoq.Mock.ofType(QueryInput, TypeMoq.MockBehavior.Strict);
|
||||
testQueryInput.setup(x => x.uri).returns(() => testUri);
|
||||
testQueryInput.setup(x => x.runQuery(undefined)).callback(() => { calledRunQueryOnInput = true; });
|
||||
|
||||
const contextkeyservice = new MockContextKeyService();
|
||||
|
||||
@@ -65,6 +63,17 @@ suite('SQL QueryAction Tests', () => {
|
||||
configurationService.setup(x => x.getValue(TypeMoq.It.isAny())).returns(() => {
|
||||
return {};
|
||||
});
|
||||
queryModelService = TypeMoq.Mock.ofType<TestQueryModelService>(TestQueryModelService);
|
||||
queryModelService.setup(q => q.onRunQueryStart).returns(() => Event.None);
|
||||
queryModelService.setup(q => q.onRunQueryComplete).returns(() => Event.None);
|
||||
connectionManagementService = TypeMoq.Mock.ofType<TestConnectionManagementService>(TestConnectionManagementService);
|
||||
connectionManagementService.setup(q => q.onDisconnect).returns(() => Event.None);
|
||||
const instantiationService = new TestInstantiationService();
|
||||
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService, undefined, undefined);
|
||||
// Setup a reusable mock QueryInput
|
||||
testQueryInput = TypeMoq.Mock.ofType(UntitledQueryEditorInput, TypeMoq.MockBehavior.Strict, undefined, fileInput, undefined, connectionManagementService.object, queryModelService.object, configurationService.object);
|
||||
testQueryInput.setup(x => x.uri).returns(() => testUri);
|
||||
testQueryInput.setup(x => x.runQuery(undefined)).callback(() => { calledRunQueryOnInput = true; });
|
||||
});
|
||||
|
||||
test('setClass sets child CSS class correctly', (done) => {
|
||||
@@ -82,7 +91,6 @@ suite('SQL QueryAction Tests', () => {
|
||||
let isConnectedReturnValue: boolean = false;
|
||||
|
||||
// ... Mock "isConnected in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService());
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnectedReturnValue);
|
||||
|
||||
const contextkeyservice = new MockContextKeyService();
|
||||
@@ -114,19 +122,15 @@ suite('SQL QueryAction Tests', () => {
|
||||
let connectionParams: INewConnectionParams = undefined;
|
||||
let countCalledShowDialog: number = 0;
|
||||
|
||||
// ... Mock "showDialog" ConnectionDialogService
|
||||
let connectionDialogService = TypeMoq.Mock.ofType(ConnectionDialogService, TypeMoq.MockBehavior.Loose);
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined, undefined))
|
||||
.callback((service: IConnectionManagementService, params: INewConnectionParams) => {
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
connectionManagementService.setup(x => x.showConnectionDialog(TypeMoq.It.isAny()))
|
||||
.callback((params: INewConnectionParams) => {
|
||||
connectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, undefined, connectionDialogService.object);
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
.returns(() => Promise.resolve());
|
||||
|
||||
// ... Mock QueryModelService
|
||||
let queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose);
|
||||
@@ -143,7 +147,6 @@ suite('SQL QueryAction Tests', () => {
|
||||
testQueryInput.verify(x => x.runQuery(undefined), TypeMoq.Times.never());
|
||||
|
||||
// and the connection dialog should open with the correct parameter details
|
||||
assert.equal(countCalledShowDialog, 1, 'run should call showDialog');
|
||||
assert.equal(connectionParams.connectionType, ConnectionType.editor, 'connectionType should be queryEditor');
|
||||
assert.equal(connectionParams.runQueryOnCompletion, RunQueryOnConnectionMode.executeQuery, 'runQueryOnCompletion should be true`');
|
||||
assert.equal(connectionParams.input.uri, testUri, 'URI should be set to the test URI');
|
||||
@@ -166,9 +169,18 @@ suite('SQL QueryAction Tests', () => {
|
||||
let isSelectionEmpty: boolean = undefined;
|
||||
let countCalledRunQuery: number = 0;
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => true);
|
||||
|
||||
// ... Mock QueryModelService
|
||||
let queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose);
|
||||
queryModelService.setup(x => x.onRunQueryStart).returns(() => Event.None);
|
||||
queryModelService.setup(x => x.onRunQueryComplete).returns(() => Event.None);
|
||||
const instantiationService = new TestInstantiationService();
|
||||
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService, undefined, undefined);
|
||||
|
||||
// ... Mock "isSelectionEmpty" in QueryEditor
|
||||
let queryInput: TypeMoq.Mock<QueryInput> = TypeMoq.Mock.ofType(QueryInput, TypeMoq.MockBehavior.Strict);
|
||||
queryInput = TypeMoq.Mock.ofType(QueryInput, TypeMoq.MockBehavior.Strict);
|
||||
let queryInput = TypeMoq.Mock.ofType(UntitledQueryEditorInput, TypeMoq.MockBehavior.Strict, undefined, fileInput, undefined, connectionManagementService.object, queryModelService.object, configurationService.object);
|
||||
queryInput.setup(x => x.uri).returns(() => testUri);
|
||||
queryInput.setup(x => x.runQuery(undefined)).callback(() => {
|
||||
countCalledRunQuery++;
|
||||
@@ -183,14 +195,6 @@ suite('SQL QueryAction Tests', () => {
|
||||
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, {});
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => true);
|
||||
|
||||
// ... Mock QueryModelService
|
||||
let queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose);
|
||||
|
||||
// If I call run on RunQueryAction when I have a non empty selection
|
||||
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, queryModelService.object, connectionManagementService.object);
|
||||
isSelectionEmpty = false;
|
||||
@@ -221,17 +225,11 @@ suite('SQL QueryAction Tests', () => {
|
||||
let selectionToReturnInGetSelection: ISelectionData = undefined;
|
||||
let predefinedSelection: ISelectionData = { startLine: 1, startColumn: 2, endLine: 3, endColumn: 4 };
|
||||
|
||||
// ... Mock "showDialog" ConnectionDialogService
|
||||
let connectionDialogService = TypeMoq.Mock.ofType(ConnectionDialogService, TypeMoq.MockBehavior.Loose);
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined, undefined))
|
||||
.callback((service: IConnectionManagementService, params: INewConnectionParams) => {
|
||||
showDialogConnectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "getSelection" in QueryEditor
|
||||
let queryInput = TypeMoq.Mock.ofType(QueryInput, TypeMoq.MockBehavior.Loose);
|
||||
const instantiationService = new TestInstantiationService();
|
||||
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService, undefined, undefined);
|
||||
|
||||
let queryInput = TypeMoq.Mock.ofType(UntitledQueryEditorInput, TypeMoq.MockBehavior.Loose, undefined, fileInput, undefined, connectionManagementService.object, queryModelService.object, configurationService.object);
|
||||
queryInput.setup(x => x.uri).returns(() => testUri);
|
||||
queryInput.setup(x => x.runQuery(TypeMoq.It.isAny())).callback((selection: ISelectionData) => {
|
||||
runQuerySelection = selection;
|
||||
@@ -256,9 +254,13 @@ suite('SQL QueryAction Tests', () => {
|
||||
});
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, undefined, connectionDialogService.object);
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
connectionManagementService.setup(x => x.showConnectionDialog(TypeMoq.It.isAny()))
|
||||
.callback((params: INewConnectionParams) => {
|
||||
showDialogConnectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => Promise.resolve());
|
||||
|
||||
/// End Setup Test ///
|
||||
|
||||
@@ -320,7 +322,6 @@ suite('SQL QueryAction Tests', () => {
|
||||
let calledCancelQuery: boolean = false;
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {});
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
|
||||
// ... Mock QueryModelService
|
||||
@@ -353,7 +354,6 @@ suite('SQL QueryAction Tests', () => {
|
||||
let countCalledDisconnectEditor: number = 0;
|
||||
|
||||
// ... Mock "isConnected" and "disconnectEditor" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {});
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
connectionManagementService.setup(x => x.disconnectEditor(TypeMoq.It.isAny())).callback(() => {
|
||||
countCalledDisconnectEditor++;
|
||||
@@ -382,19 +382,14 @@ suite('SQL QueryAction Tests', () => {
|
||||
let connectionParams: INewConnectionParams = undefined;
|
||||
let countCalledShowDialog: number = 0;
|
||||
|
||||
// ... Mock "showDialog" ConnectionDialogService
|
||||
let connectionDialogService = TypeMoq.Mock.ofType(ConnectionDialogService, TypeMoq.MockBehavior.Loose);
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined, undefined))
|
||||
.callback((service: IConnectionManagementService, params: INewConnectionParams) => {
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
connectionManagementService.setup(x => x.showConnectionDialog(TypeMoq.It.isAny()))
|
||||
.callback((params: INewConnectionParams) => {
|
||||
connectionParams = params;
|
||||
countCalledShowDialog++;
|
||||
})
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, undefined, connectionDialogService.object);
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
.returns(() => Promise.resolve());
|
||||
|
||||
// If I call run on ConnectDatabaseAction when I am not connected
|
||||
let queryAction: ConnectDatabaseAction = new ConnectDatabaseAction(editor.object, false, connectionManagementService.object);
|
||||
@@ -428,19 +423,13 @@ suite('SQL QueryAction Tests', () => {
|
||||
let connectionParams: INewConnectionParams = undefined;
|
||||
let calledShowDialog: number = 0;
|
||||
|
||||
// ... Mock "showDialog" ConnectionDialogService
|
||||
let connectionDialogService = TypeMoq.Mock.ofType(ConnectionDialogService, TypeMoq.MockBehavior.Loose);
|
||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined, undefined))
|
||||
.callback((service: IConnectionManagementService, params: INewConnectionParams) => {
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
connectionManagementService.setup(x => x.showConnectionDialog(TypeMoq.It.isAny()))
|
||||
.callback((params: INewConnectionParams) => {
|
||||
calledShowDialog++;
|
||||
connectionParams = params;
|
||||
})
|
||||
.returns(() => Promise.resolve(none));
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, undefined, connectionDialogService.object);
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
}).returns(() => Promise.resolve());
|
||||
|
||||
// If I call run on ChangeConnectionAction when I am not connected
|
||||
queryAction = new ConnectDatabaseAction(editor.object, false, connectionManagementService.object);
|
||||
@@ -473,9 +462,8 @@ suite('SQL QueryAction Tests', () => {
|
||||
let databaseName: string = undefined;
|
||||
|
||||
// ... Mock "isConnected" in ConnectionManagementService
|
||||
let connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {});
|
||||
connectionManagementService.callBase = true;
|
||||
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnected);
|
||||
connectionManagementService.setup(x => x.onConnectionChanged).returns(() => Event.None);
|
||||
connectionManagementService.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{
|
||||
databaseName: databaseName
|
||||
});
|
||||
@@ -510,13 +498,11 @@ suite('SQL QueryAction Tests', () => {
|
||||
|
||||
// ... Create mock connection management service
|
||||
let databaseName = 'foobar';
|
||||
let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {});
|
||||
cms.callBase = true;
|
||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||
connectionManagementService.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||
connectionManagementService.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||
|
||||
// ... Create a database dropdown that has been connected
|
||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, cms.object, undefined, configurationService.object);
|
||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object);
|
||||
listItem.onConnected();
|
||||
|
||||
// If: I raise a connection changed event
|
||||
@@ -534,13 +520,11 @@ 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, {}, {}, new TestStorageService());
|
||||
cms.callBase = true;
|
||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||
connectionManagementService.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||
connectionManagementService.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||
|
||||
// ... Create a database dropdown that has been connected
|
||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, cms.object, undefined, configurationService.object);
|
||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object);
|
||||
listItem.onConnected();
|
||||
|
||||
// If: I raise a connection changed event for the 'wrong' URI
|
||||
@@ -562,12 +546,10 @@ suite('SQL QueryAction Tests', () => {
|
||||
let dbChangedEmitter = new Emitter<IConnectionParams>();
|
||||
|
||||
// ... Create mock connection management service
|
||||
let cms = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, {}, {}, new TestStorageService());
|
||||
cms.callBase = true;
|
||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||
connectionManagementService.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||
|
||||
// ... Create a database dropdown
|
||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, cms.object, undefined, configurationService.object);
|
||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object);
|
||||
|
||||
// If: I raise a connection changed event
|
||||
let eventParams = <IConnectionParams>{
|
||||
|
||||
@@ -10,8 +10,6 @@ import { Memento } from 'vs/workbench/common/memento';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryModelService } from 'sql/platform/query/common/queryModelService';
|
||||
import { QueryInput } from 'sql/workbench/contrib/query/common/queryInput';
|
||||
import { INewConnectionParams, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionManagementService } from 'sql/workbench/services/connection/browser/connectionManagementService';
|
||||
import { RunQueryAction, ListDatabasesActionItem } from 'sql/workbench/contrib/query/browser/queryActions';
|
||||
@@ -23,6 +21,9 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { TestQueryModelService } from 'sql/platform/query/test/common/testQueryModelService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
suite('SQL QueryEditor Tests', () => {
|
||||
let instantiationService: TypeMoq.Mock<InstantiationService>;
|
||||
@@ -247,8 +248,8 @@ suite('SQL QueryEditor Tests', () => {
|
||||
suite('Action Tests', () => {
|
||||
let queryActionInstantiationService: TypeMoq.Mock<InstantiationService>;
|
||||
let queryConnectionService: TypeMoq.Mock<ConnectionManagementService>;
|
||||
let queryModelService: TypeMoq.Mock<QueryModelService>;
|
||||
let queryInput: QueryInput;
|
||||
let queryModelService: TypeMoq.Mock<TestQueryModelService>;
|
||||
let queryInput: UntitledQueryEditorInput;
|
||||
setup(() => {
|
||||
|
||||
// Mock ConnectionManagementService but don't set connected state
|
||||
@@ -284,17 +285,17 @@ suite('SQL QueryEditor Tests', () => {
|
||||
});
|
||||
|
||||
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService.object, undefined, undefined);
|
||||
queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose, undefined, undefined);
|
||||
queryModelService.callBase = true;
|
||||
queryModelService.setup(x => x.disposeQuery(TypeMoq.It.isAny())).returns(() => void 0);
|
||||
queryInput = new QueryInput(
|
||||
queryModelService = TypeMoq.Mock.ofType(TestQueryModelService, TypeMoq.MockBehavior.Strict);
|
||||
queryModelService.setup(x => x.disposeQuery(TypeMoq.It.isAny()));
|
||||
queryModelService.setup(x => x.onRunQueryComplete).returns(() => Event.None);
|
||||
queryModelService.setup(x => x.onRunQueryStart).returns(() => Event.None);
|
||||
queryInput = new UntitledQueryEditorInput(
|
||||
'',
|
||||
fileInput,
|
||||
undefined,
|
||||
undefined,
|
||||
connectionManagementService.object,
|
||||
queryModelService.object,
|
||||
undefined,
|
||||
configurationService.object,
|
||||
undefined
|
||||
);
|
||||
});
|
||||
@@ -311,8 +312,8 @@ suite('SQL QueryEditor Tests', () => {
|
||||
|
||||
test('Taskbar buttons are set correctly upon connect', () => {
|
||||
let params: INewConnectionParams = { connectionType: ConnectionType.editor, runQueryOnCompletion: RunQueryOnConnectionMode.none };
|
||||
queryInput.onConnectSuccess(params);
|
||||
queryModelService.setup(x => x.isRunningQuery(TypeMoq.It.isAny())).returns(() => false);
|
||||
queryInput.onConnectSuccess(params);
|
||||
assert.equal(queryInput.state.connected, true, 'query state should be not connected');
|
||||
assert.equal(queryInput.state.executing, false, 'query state should be not executing');
|
||||
assert.equal(queryInput.state.connecting, false, 'query state should be not connecting');
|
||||
|
||||
Reference in New Issue
Block a user