mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
273
src/sqltest/workbench/api/extHostAccountManagement.test.ts
Normal file
273
src/sqltest/workbench/api/extHostAccountManagement.test.ts
Normal file
@@ -0,0 +1,273 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as data from 'data';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { AccountProviderStub, AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
||||
import { ExtHostAccountManagement } from 'sql/workbench/api/node/extHostAccountManagement';
|
||||
import { TestThreadService } from 'vs/workbench/test/electron-browser/api/testThreadService';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { SqlMainContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { MainThreadAccountManagement } from 'sql/workbench/api/node/mainThreadAccountManagement';
|
||||
import { IAccountManagementService } from 'sql/services/accountManagement/interfaces';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const IThreadService = createDecorator<IThreadService>('threadService');
|
||||
|
||||
// SUITE STATE /////////////////////////////////////////////////////////////
|
||||
let instantiationService: TestInstantiationService;
|
||||
let mockAccountMetadata: data.AccountProviderMetadata;
|
||||
let mockAccount: data.Account;
|
||||
let threadService: TestThreadService;
|
||||
|
||||
// TESTS ///////////////////////////////////////////////////////////////////
|
||||
suite('ExtHostAccountManagement', () => {
|
||||
suiteSetup(() => {
|
||||
threadService = new TestThreadService();
|
||||
const accountMgmtStub = new AccountManagementTestService();
|
||||
|
||||
instantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IThreadService, threadService);
|
||||
instantiationService.stub(IAccountManagementService, accountMgmtStub);
|
||||
|
||||
const accountMgmtService = instantiationService.createInstance(MainThreadAccountManagement);
|
||||
threadService.setTestInstance(SqlMainContext.MainThreadAccountManagement, accountMgmtService);
|
||||
|
||||
mockAccountMetadata = {
|
||||
args: {},
|
||||
displayName: 'Test Account Provider',
|
||||
id: 'test_account_provider',
|
||||
settings: {}
|
||||
};
|
||||
mockAccount = {
|
||||
key: {
|
||||
providerId: mockAccountMetadata.id,
|
||||
providerArgs: {},
|
||||
accountId: 'test_account'
|
||||
},
|
||||
properties: {},
|
||||
displayInfo: {
|
||||
displayName: 'Test Account',
|
||||
contextualDisplayName: 'Test Kind Of Account',
|
||||
contextualLogo: { light: '', dark: '' }
|
||||
},
|
||||
isStale: false
|
||||
};
|
||||
});
|
||||
|
||||
test('Constructor', () => {
|
||||
// If: I construct a new extension host account management
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
|
||||
// Then: There shouldn't be any account providers registered
|
||||
assert.equal(extHost.getProviderCount(), 0);
|
||||
});
|
||||
|
||||
// REGISTER TESTS //////////////////////////////////////////////////////
|
||||
test('Register Account Provider - Success', () => {
|
||||
// Setup: Create an extension host account management
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
|
||||
// If: I register a mock account provider
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// Then: The account provider should be registered
|
||||
assert.equal(extHost.getProviderCount(), 1);
|
||||
});
|
||||
|
||||
test('Register Account Provider - Account Provider Already Registered', () => {
|
||||
// Setup: Create an extension host account management and register an account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I register an account provider again
|
||||
// Then
|
||||
// ... It should throw
|
||||
assert.throws(() => {
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
});
|
||||
|
||||
// ... There should only be one account provider
|
||||
assert.equal(extHost.getProviderCount(), 1);
|
||||
});
|
||||
|
||||
// TODO: Test for unregistering a provider
|
||||
|
||||
// CLEAR TESTS /////////////////////////////////////////////////////////
|
||||
test('Clear - Success', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I clear an account
|
||||
extHost.$clear(0, mockAccount.key)
|
||||
.then(() => {
|
||||
// Then: The call should have been passed to the provider
|
||||
mockProvider.verify(
|
||||
(obj) => obj.clear(TypeMoq.It.isValue(mockAccount.key)),
|
||||
TypeMoq.Times.once()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
test('Clear - Handle does not exist', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I clear an account for a handle that doesn't exist
|
||||
// Then: It should fail
|
||||
extHost.$clear(1, mockAccount.key)
|
||||
.then(() => done('Clear succeeded when it should have failed'))
|
||||
.then(null, () => {
|
||||
// The provider's clear should not have been called
|
||||
mockProvider.verify(
|
||||
(obj) => obj.clear(TypeMoq.It.isAny()),
|
||||
TypeMoq.Times.never()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
// INITIALIZE TESTS ////////////////////////////////////////////////////
|
||||
test('Initialize - Success', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I initialize the provider
|
||||
extHost.$initialize(0, [mockAccount])
|
||||
.then(() => {
|
||||
// Then: The call should have been passed to the provider
|
||||
mockProvider.verify(
|
||||
(obj) => obj.initialize(TypeMoq.It.isValue([mockAccount])),
|
||||
TypeMoq.Times.once()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
test('Initialize - Handle does not exist', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I initialize for a handle that doesn't exist
|
||||
// Then: It should fail
|
||||
extHost.$initialize(1, [mockAccount])
|
||||
.then(() => done('Initialize succeeded when it should have failed'))
|
||||
.then(null, () => {
|
||||
// The provider's clear should not have been called
|
||||
mockProvider.verify(
|
||||
(obj) => obj.initialize(TypeMoq.It.isAny()),
|
||||
TypeMoq.Times.never()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
// PROMPT TESTS ////////////////////////////////////////////////////////
|
||||
test('Prompt - Success', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I prompt for an account
|
||||
extHost.$prompt(0)
|
||||
.then(() => {
|
||||
// Then: The call should have been passed to the provider
|
||||
mockProvider.verify(
|
||||
(obj) => obj.prompt(),
|
||||
TypeMoq.Times.once()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
test('Prompt - Handle does not exist', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I prompt with a handle that doesn't exist
|
||||
// Then: It should fail
|
||||
extHost.$prompt(1)
|
||||
.then(() => done('Prompt succeeded when it should have failed'))
|
||||
.then(null, () => {
|
||||
// The provider's clear should not have been called
|
||||
mockProvider.verify(
|
||||
(obj) => obj.prompt(),
|
||||
TypeMoq.Times.never()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
// REFRESH TESTS ///////////////////////////////////////////////////////
|
||||
test('Refresh - Success', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I refresh an account
|
||||
extHost.$refresh(0, mockAccount)
|
||||
.then(() => {
|
||||
// Then: The call should have been passed to the provider
|
||||
mockProvider.verify(
|
||||
(obj) => obj.refresh(TypeMoq.It.isValue(mockAccount)),
|
||||
TypeMoq.Times.once()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
test('Refresh - Handle does not exist', (done) => {
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
let extHost = new ExtHostAccountManagement(threadService);
|
||||
let mockProvider = getMockAccountProvider();
|
||||
extHost.$registerAccountProvider(mockAccountMetadata, mockProvider.object);
|
||||
|
||||
// If: I refresh an account for a handle that doesn't exist
|
||||
// Then: It should fail
|
||||
extHost.$refresh(1, mockAccount)
|
||||
.then(() => done('Refresh succeeded when it should have failed'))
|
||||
.then(null, () => {
|
||||
// The provider's clear should not have been called
|
||||
mockProvider.verify(
|
||||
(obj) => obj.refresh(TypeMoq.It.isAny()),
|
||||
TypeMoq.Times.never()
|
||||
);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
function getMockAccountProvider(): TypeMoq.Mock<data.AccountProvider> {
|
||||
let mock = TypeMoq.Mock.ofType<data.AccountProvider>(AccountProviderStub);
|
||||
mock.setup((obj) => obj.clear(TypeMoq.It.isValue(mockAccount.key)))
|
||||
.returns(() => Promise.resolve(undefined));
|
||||
mock.setup((obj) => obj.refresh(TypeMoq.It.isValue(mockAccount)))
|
||||
.returns(() => Promise.resolve(undefined));
|
||||
mock.setup((obj) => obj.initialize(TypeMoq.It.isValue([mockAccount])))
|
||||
.returns(() => Promise.resolve(undefined));
|
||||
mock.setup((obj) => obj.prompt())
|
||||
.returns(() => Promise.resolve(undefined));
|
||||
|
||||
return mock;
|
||||
}
|
||||
133
src/sqltest/workbench/api/extHostCredentialManagement.test.ts
Normal file
133
src/sqltest/workbench/api/extHostCredentialManagement.test.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import {TestThreadService} from 'vs/workbench/test/electron-browser/api/testThreadService';
|
||||
import {TestInstantiationService} from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import {ExtHostCredentialManagement} from 'sql/workbench/api/node/extHostCredentialManagement';
|
||||
import {SqlMainContext} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
|
||||
import {MainThreadCredentialManagement} from 'sql/workbench/api/node/mainThreadCredentialManagement';
|
||||
import {CredentialsTestProvider, CredentialsTestService} from 'sqltest/stubs/credentialsTestStubs';
|
||||
import {ICredentialsService} from 'sql/services/credentials/credentialsService';
|
||||
import {Credential, CredentialProvider} from 'data';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const IThreadService = createDecorator<IThreadService>('threadService');
|
||||
|
||||
// SUITE STATE /////////////////////////////////////////////////////////////
|
||||
let credentialServiceStub: CredentialsTestService;
|
||||
let instantiationService: TestInstantiationService;
|
||||
let threadService: TestThreadService;
|
||||
|
||||
// TESTS ///////////////////////////////////////////////////////////////////
|
||||
suite('ExtHostCredentialManagement', () => {
|
||||
suiteSetup(() => {
|
||||
threadService = new TestThreadService();
|
||||
credentialServiceStub = new CredentialsTestService();
|
||||
|
||||
instantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IThreadService, threadService);
|
||||
instantiationService.stub(ICredentialsService, credentialServiceStub);
|
||||
|
||||
const credentialService = instantiationService.createInstance(MainThreadCredentialManagement);
|
||||
threadService.setTestInstance(SqlMainContext.MainThreadCredentialManagement, credentialService);
|
||||
});
|
||||
|
||||
test('Construct ExtHostCredentialManagement', () => {
|
||||
// If: I construct an credential management extension host
|
||||
let extHost = new ExtHostCredentialManagement(threadService);
|
||||
|
||||
// Then: The extension host should not have any providers registered
|
||||
assert.equal(extHost.getProviderCount(), 0);
|
||||
});
|
||||
|
||||
test('Register Credential Provider', () => {
|
||||
// Setup: Create a mock credential provider
|
||||
let extHost = new ExtHostCredentialManagement(threadService);
|
||||
let mockCredentialProvider = new CredentialsTestProvider();
|
||||
|
||||
// If: I register the credential provider with the extension host
|
||||
extHost.$registerCredentialProvider(mockCredentialProvider);
|
||||
|
||||
// Then: There should be one provider registered
|
||||
assert.equal(extHost.getProviderCount(), 1);
|
||||
});
|
||||
|
||||
test('Get Credential Provider - Success', (done) => {
|
||||
// Setup: Register a mock credential provider
|
||||
let extHost = new ExtHostCredentialManagement(threadService);
|
||||
let mockCredentialProvider = new CredentialsTestProvider();
|
||||
extHost.$registerCredentialProvider(mockCredentialProvider);
|
||||
|
||||
// If: I get the credential provider
|
||||
let namespaceId = 'test_namespace';
|
||||
let credentialId = 'test_id';
|
||||
let credential = 'test_credential';
|
||||
let expectedCredentialId = `${namespaceId}|${credentialId}`;
|
||||
let credProvider: CredentialProvider;
|
||||
extHost.$getCredentialProvider(namespaceId)
|
||||
.then((provider) => {
|
||||
// Then: There should still only be one provider registered
|
||||
assert.equal(extHost.getProviderCount(), 1);
|
||||
credProvider = provider;
|
||||
})
|
||||
.then(() => {
|
||||
// If: I write a credential
|
||||
return credProvider.saveCredential(credentialId, credential);
|
||||
})
|
||||
.then(() => {
|
||||
// Then: The credential should have been stored with its namespace
|
||||
assert.notStrictEqual(mockCredentialProvider.storedCredentials[expectedCredentialId], undefined);
|
||||
assert.equal(mockCredentialProvider.storedCredentials[expectedCredentialId].credentialId, expectedCredentialId);
|
||||
assert.equal(mockCredentialProvider.storedCredentials[expectedCredentialId].password, credential);
|
||||
})
|
||||
.then(() => {
|
||||
// If: I read a credential
|
||||
return credProvider.readCredential(credentialId);
|
||||
})
|
||||
.then((returnedCredential: Credential) => {
|
||||
// Then: The credential ID should be namespaced
|
||||
assert.equal(returnedCredential.credentialId, expectedCredentialId);
|
||||
assert.equal(returnedCredential.password, credential);
|
||||
})
|
||||
.then(() => {
|
||||
// If: I delete a credential
|
||||
return credProvider.deleteCredential(credentialId);
|
||||
})
|
||||
.then(() => {
|
||||
// Then: The credential with its namespace should no longer exist
|
||||
assert.strictEqual(mockCredentialProvider.storedCredentials[expectedCredentialId], undefined);
|
||||
})
|
||||
.then(() => done(), (err) => done(err));
|
||||
});
|
||||
|
||||
test('Get Credential Provider - No Namespace', (done) => {
|
||||
// Setup: Register a mock credential provider
|
||||
let extHost = new ExtHostCredentialManagement(threadService);
|
||||
let mockCredentialProvider = new CredentialsTestProvider();
|
||||
extHost.$registerCredentialProvider(mockCredentialProvider);
|
||||
|
||||
// If: I get a credential provider with an invalid namespace ID
|
||||
// Then: I should get an error
|
||||
extHost.$getCredentialProvider(undefined)
|
||||
.then(
|
||||
() => { done('Provider was returned from undefined'); },
|
||||
() => { /* Swallow error, this is success path */ }
|
||||
)
|
||||
.then(() => { return extHost.$getCredentialProvider(null); })
|
||||
.then(
|
||||
() => { done('Provider was returned from null'); },
|
||||
() => { /* Swallow error, this is success path */ }
|
||||
)
|
||||
.then(() => {return extHost.$getCredentialProvider(''); })
|
||||
.then(
|
||||
() => { done('Provider was returned from \'\''); },
|
||||
() => { done(); }
|
||||
);
|
||||
});
|
||||
});
|
||||
129
src/sqltest/workbench/api/extHostDataProtocol.test.ts
Normal file
129
src/sqltest/workbench/api/extHostDataProtocol.test.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { setUnexpectedErrorHandler, errorHandler } from 'vs/base/common/errors';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import { Model as EditorModel } from 'vs/editor/common/model/model';
|
||||
import { TestThreadService } from 'vs/workbench/test/electron-browser/api/testThreadService';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { MarkerService } from 'vs/platform/markers/common/markerService';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { MainThreadCommands } from 'vs/workbench/api/electron-browser/mainThreadCommands';
|
||||
import { IHeapService } from 'vs/workbench/api/electron-browser/mainThreadHeapService';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors';
|
||||
import { DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import * as data from 'data';
|
||||
import { ExtHostDataProtocol } from 'sql/workbench/api/node/extHostDataProtocol';
|
||||
import { SqlExtHostContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
const IThreadService = createDecorator<IThreadService>('threadService');
|
||||
|
||||
const model: EditorCommon.IModel = EditorModel.createFromString(
|
||||
[
|
||||
'This is the first line',
|
||||
'This is the second line',
|
||||
'This is the third line',
|
||||
].join('\n'),
|
||||
undefined,
|
||||
undefined,
|
||||
URI.parse('far://testing/file.a'));
|
||||
|
||||
let extHost: ExtHostDataProtocol;
|
||||
let disposables: vscode.Disposable[] = [];
|
||||
let threadService: TestThreadService;
|
||||
let originalErrorHandler: (e: any) => any;
|
||||
|
||||
suite('ExtHostDataProtocol', function () {
|
||||
|
||||
suiteSetup(() => {
|
||||
|
||||
threadService = new TestThreadService();
|
||||
let instantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IThreadService, threadService);
|
||||
instantiationService.stub(IMarkerService, MarkerService);
|
||||
instantiationService.stub(IHeapService, {
|
||||
_serviceBrand: undefined,
|
||||
trackRecursive(args) {
|
||||
// nothing
|
||||
return args;
|
||||
}
|
||||
});
|
||||
|
||||
originalErrorHandler = errorHandler.getUnexpectedErrorHandler();
|
||||
setUnexpectedErrorHandler(() => { });
|
||||
|
||||
const extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(threadService);
|
||||
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({
|
||||
addedDocuments: [{
|
||||
isDirty: false,
|
||||
versionId: model.getVersionId(),
|
||||
modeId: model.getLanguageIdentifier().language,
|
||||
url: model.uri,
|
||||
lines: model.getValue().split(model.getEOL()),
|
||||
EOL: model.getEOL(),
|
||||
}]
|
||||
});
|
||||
const extHostDocuments = new ExtHostDocuments(threadService, extHostDocumentsAndEditors);
|
||||
threadService.set(ExtHostContext.ExtHostDocuments, extHostDocuments);
|
||||
|
||||
const heapService = new ExtHostHeapService();
|
||||
|
||||
const commands = new ExtHostCommands(threadService, heapService);
|
||||
threadService.set(ExtHostContext.ExtHostCommands, commands);
|
||||
threadService.setTestInstance(MainContext.MainThreadCommands, instantiationService.createInstance(MainThreadCommands));
|
||||
|
||||
const diagnostics = new ExtHostDiagnostics(threadService);
|
||||
threadService.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostDataProtocol(threadService);
|
||||
threadService.set(SqlExtHostContext.ExtHostDataProtocol, extHost);
|
||||
});
|
||||
|
||||
suiteTeardown(() => {
|
||||
setUnexpectedErrorHandler(originalErrorHandler);
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
while (disposables.length) {
|
||||
disposables.pop().dispose();
|
||||
}
|
||||
return threadService.sync();
|
||||
});
|
||||
|
||||
// --- outline
|
||||
|
||||
test('DataProvider, language flavor changed', function () {
|
||||
assert.equal(DocumentSymbolProviderRegistry.all(model).length, 0);
|
||||
let expectedParams = <data.DidChangeLanguageFlavorParams> {
|
||||
uri: 'myuri',
|
||||
language: 'sql'
|
||||
};
|
||||
let actualParams: data.DidChangeLanguageFlavorParams = undefined;
|
||||
extHost.onDidChangeLanguageFlavor((e => {
|
||||
actualParams = e;
|
||||
}));
|
||||
|
||||
extHost.$languageFlavorChanged(expectedParams);
|
||||
|
||||
assert.ok(actualParams !== undefined);
|
||||
assert.equal(actualParams.uri, expectedParams.uri);
|
||||
assert.equal(actualParams.flavor, expectedParams.flavor);
|
||||
assert.equal(actualParams.language, expectedParams.language);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user