SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------------------------
* 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 { IDisposable } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { CommandService } from 'vs/platform/commands/common/commandService';
import { IExtensionService, ExtensionPointContribution, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { IExtensionPoint } from 'vs/platform/extensions/common/extensionsRegistry';
class SimpleExtensionService implements IExtensionService {
_serviceBrand: any;
activateByEvent(activationEvent: string): TPromise<void> {
return this.onReady().then(() => { });
}
onReady(): TPromise<boolean> {
return TPromise.as(true);
}
readExtensionPointContributions<T>(extPoint: IExtensionPoint<T>): TPromise<ExtensionPointContribution<T>[]> {
return TPromise.as([]);
}
getExtensionsStatus() {
return undefined;
}
getExtensionsActivationTimes() {
return undefined;
}
getExtensions(): TPromise<IExtensionDescription[]> {
return TPromise.wrap([]);
}
restartExtensionHost(): void {
}
}
suite('CommandService', function () {
let commandRegistration: IDisposable;
setup(function () {
commandRegistration = CommandsRegistry.registerCommand('foo', function () { });
});
teardown(function () {
commandRegistration.dispose();
});
test('activateOnCommand', function () {
let lastEvent: string;
let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService {
activateByEvent(activationEvent: string): TPromise<void> {
lastEvent = activationEvent;
return super.activateByEvent(activationEvent);
}
});
return service.executeCommand('foo').then(() => {
assert.ok(lastEvent, 'onCommand:foo');
return service.executeCommand('unknownCommandId');
}).then(() => {
assert.ok(false);
}, () => {
assert.ok(lastEvent, 'onCommand:unknownCommandId');
});
});
test('fwd activation error', function () {
let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService {
activateByEvent(activationEvent: string): TPromise<void> {
return TPromise.wrapError<void>(new Error('bad_activate'));
}
});
return service.executeCommand('foo').then(() => assert.ok(false), err => {
assert.equal(err.message, 'bad_activate');
});
});
test('!onReady, but executeCommand', function () {
let callCounter = 0;
let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1);
let resolve: Function;
let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService {
onReady() {
return new TPromise<boolean>(_resolve => { resolve = _resolve; });
}
});
return service.executeCommand('bar').then(() => {
reg.dispose();
assert.equal(callCounter, 1);
});
});
});