mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-29 00:00:29 -04:00
Merge from master
This commit is contained in:
55
src/vs/platform/instantiation/test/common/graph.test.ts
Normal file
55
src/vs/platform/instantiation/test/common/graph.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { Graph } from 'vs/platform/instantiation/common/graph';
|
||||
|
||||
suite('Graph', () => {
|
||||
var graph: Graph<string>;
|
||||
|
||||
setup(() => {
|
||||
graph = new Graph<string>(s => s);
|
||||
});
|
||||
|
||||
test('is possible to lookup nodes that don\'t exist', function () {
|
||||
assert.deepEqual(graph.lookup('ddd'), null);
|
||||
});
|
||||
|
||||
test('inserts nodes when not there yet', function () {
|
||||
assert.deepEqual(graph.lookup('ddd'), null);
|
||||
assert.deepEqual(graph.lookupOrInsertNode('ddd').data, 'ddd');
|
||||
assert.deepEqual(graph.lookup('ddd').data, 'ddd');
|
||||
});
|
||||
|
||||
test('can remove nodes and get length', function () {
|
||||
assert.ok(graph.isEmpty());
|
||||
assert.deepEqual(graph.lookup('ddd'), null);
|
||||
assert.deepEqual(graph.lookupOrInsertNode('ddd').data, 'ddd');
|
||||
assert.ok(!graph.isEmpty());
|
||||
graph.removeNode('ddd');
|
||||
assert.deepEqual(graph.lookup('ddd'), null);
|
||||
assert.ok(graph.isEmpty());
|
||||
});
|
||||
|
||||
test('root', () => {
|
||||
graph.insertEdge('1', '2');
|
||||
var roots = graph.roots();
|
||||
assert.equal(roots.length, 1);
|
||||
assert.equal(roots[0].data, '2');
|
||||
|
||||
graph.insertEdge('2', '1');
|
||||
roots = graph.roots();
|
||||
assert.equal(roots.length, 0);
|
||||
});
|
||||
|
||||
test('root complex', function () {
|
||||
graph.insertEdge('1', '2');
|
||||
graph.insertEdge('1', '3');
|
||||
graph.insertEdge('3', '4');
|
||||
|
||||
var roots = graph.roots();
|
||||
assert.equal(roots.length, 2);
|
||||
assert(['2', '4'].every(n => roots.some(node => node.data === n)));
|
||||
});
|
||||
});
|
||||
@@ -2,8 +2,6 @@
|
||||
* 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 { createDecorator, optional, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as sinon from 'sinon';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
interface IServiceMock<T> {
|
||||
id: ServiceIdentifier<T>;
|
||||
|
||||
Reference in New Issue
Block a user