当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript instantiationTestUtils.TestInstantiationService类代码示例

本文整理汇总了TypeScript中vs/test/utils/instantiationTestUtils.TestInstantiationService的典型用法代码示例。如果您正苦于以下问题:TypeScript TestInstantiationService类的具体用法?TypeScript TestInstantiationService怎么用?TypeScript TestInstantiationService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestInstantiationService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setup

	setup(() => {
		instantiationService = new TestInstantiationService();
		modeService = instantiationService.stub(IModeService);
	});
开发者ID:asotog,项目名称:vscode,代码行数:4,代码来源:editorModel.test.ts

示例2: suite

suite('SearchModel', () => {

	let instantiationService: TestInstantiationService;
	let restoreStubs;

	setup(() => {
		restoreStubs= [];
		instantiationService= new TestInstantiationService();
		instantiationService.stub(ITelemetryService);
		instantiationService.stub(IModelService, createMockModelService(instantiationService));
	});

	teardown(() => {
		restoreStubs.forEach(element => {
			element.restore();
		});
	});

	test('Search Model: Search adds to results', function () {
		let results= [aRawMatch('file://c:/1', aLineMatch('preview 1', 1, [[1, 3], [4, 7]])), aRawMatch('file://c:/2', aLineMatch('preview 2'))];
		instantiationService.stub(ISearchService, 'search',  PPromise.as({results: results}));

		let testObject= instantiationService.createInstance(SearchModel);
		testObject.search({contentPattern: {pattern: 'somestring'}, type: 1});

		let actual= testObject.searchResult.matches();

		assert.equal(2, actual.length);
		assert.equal('file://c:/1', actual[0].resource().toString());

		let actuaMatches= actual[0].matches();
		assert.equal(2, actuaMatches.length);
		assert.equal('preview 1', actuaMatches[0].text());
		assert.ok(new Range(2, 2, 2, 5).equalsRange(actuaMatches[0].range()));
		assert.equal('preview 1', actuaMatches[1].text());
		assert.ok(new Range(2, 5, 2, 12).equalsRange(actuaMatches[1].range()));

		actuaMatches= actual[1].matches();
		assert.equal(1, actuaMatches.length);
		assert.equal('preview 2', actuaMatches[0].text());
		assert.ok(new Range(2, 1, 2, 2).equalsRange(actuaMatches[0].range()));
	});

	test('Search Model: Search adds to results during progress', function (done) {
		let results= [aRawMatch('file://c:/1', aLineMatch('preview 1', 1, [[1, 3], [4, 7]])), aRawMatch('file://c:/2', aLineMatch('preview 2'))];
		let promise= new DeferredPPromise<ISearchComplete, ISearchProgressItem>();
		instantiationService.stub(ISearchService, 'search',  promise);

		let testObject= instantiationService.createInstance(SearchModel);
		let result= testObject.search({contentPattern: {pattern: 'somestring'}, type: 1});

		promise.progress(results[0]);
		promise.progress(results[1]);
		promise.complete({results: []});

		result.done(() => {
			let actual= testObject.searchResult.matches();

			assert.equal(2, actual.length);
			assert.equal('file://c:/1', actual[0].resource().toString());

			let actuaMatches= actual[0].matches();
			assert.equal(2, actuaMatches.length);
			assert.equal('preview 1', actuaMatches[0].text());
			assert.ok(new Range(2, 2, 2, 5).equalsRange(actuaMatches[0].range()));
			assert.equal('preview 1', actuaMatches[1].text());
			assert.ok(new Range(2, 5, 2, 12).equalsRange(actuaMatches[1].range()));

			actuaMatches= actual[1].matches();
			assert.equal(1, actuaMatches.length);
			assert.equal('preview 2', actuaMatches[0].text());
			assert.ok(new Range(2, 1, 2, 2).equalsRange(actuaMatches[0].range()));

			done();
		});
	});

	test('Search Model: Search reports telemetry on search completed', function () {
		let target= instantiationService.spy(ITelemetryService, 'publicLog');
		let results= [aRawMatch('file://c:/1', aLineMatch('preview 1', 1, [[1, 3], [4, 7]])), aRawMatch('file://c:/2', aLineMatch('preview 2'))];
		instantiationService.stub(ISearchService, 'search',  PPromise.as({results: results}));

		let testObject= instantiationService.createInstance(SearchModel);
		testObject.search({contentPattern: {pattern: 'somestring'}, type: 1});

		assert.ok(target.calledOnce);
		assert.deepEqual(['searchResultsShown', {count: 3, fileCount: 2}], target.args[0]);
	});

	test('Search Model: Search reports timed telemetry on search when progress is not called', function () {
		let target2= sinon.spy();
		stub(nullEvent, 'stop', target2);
		let target1= sinon.stub().returns(nullEvent);
		instantiationService.stub(ITelemetryService, 'timedPublicLog', target1);

		instantiationService.stub(ISearchService, 'search',  PPromise.as({results: []}));

		let testObject= instantiationService.createInstance(SearchModel);
		testObject.search({contentPattern: {pattern: 'somestring'}, type: 1});

//.........这里部分代码省略.........
开发者ID:baltth,项目名称:vscode,代码行数:101,代码来源:searchModel.test.ts

示例3: setup

	setup(() => {
		instantiation = new TestInstantiationService();
		instantiation.stub(IModelService, createMockModelService(instantiation));
	});
开发者ID:asotog,项目名称:vscode,代码行数:4,代码来源:searchViewlet.test.ts

示例4: suite

suite('Workbench - EditorModel', () => {

	let instantiationService: TestInstantiationService;
	let modeService: IModeService;

	setup(() => {
		instantiationService = new TestInstantiationService();
		modeService = instantiationService.stub(IModeService);
	});

	test('EditorModel', function (done) {
		let counter = 0;

		let m = new MyEditorModel();

		m.onDispose(() => {
			assert(true);
			counter++;
		});

		m.load().then(model => {
			assert(model === m);
			assert.strictEqual(m.isResolved(), true);
			m.dispose();
			assert.equal(counter, 1);
		}).done(() => done());
	});

	test('BaseTextEditorModel', function (done) {
		let modelService = createMockModelService(instantiationService);

		let m = new MyTextEditorModel(modelService, modeService);
		m.load().then((model: any) => {
			assert(model === m);
			return model.createTextEditorModel('foo', null, 'text/plain').then(() => {
				assert.strictEqual(m.isResolved(), true);
			});
		}).done(() => {
			m.dispose();
			done();
		});
	});

	test('TextDiffEditorModel', function (done) {
		instantiationService.stub(IModelService, createMockModelService(instantiationService));
		let input = instantiationService.createInstance(StringEditorInput, 'name', 'description', 'value', 'text/plain', false);
		let otherInput = instantiationService.createInstance(StringEditorInput, 'name2', 'description', 'value2', 'text/plain', false);
		let diffInput = new DiffEditorInput('name', 'description', input, otherInput);

		diffInput.resolve(true).then((model: any) => {
			assert(model);
			assert(model instanceof TextDiffEditorModel);

			let diffEditorModel = model.textDiffEditorModel;
			assert(diffEditorModel.original);
			assert(diffEditorModel.modified);

			return diffInput.resolve(true).then((model: any) => {
				assert(model.isResolved());

				assert(diffEditorModel !== model.textDiffEditorModel);
				diffInput.dispose();
				assert(!model.textDiffEditorModel);
			});
		}).done(() => {
			done();
		});
	});
});
开发者ID:asotog,项目名称:vscode,代码行数:69,代码来源:editorModel.test.ts

示例5: setup

	setup(() => {
		instantiationService= new TestInstantiationService();
		instantiationService.stub(IExtensionService);
	});
开发者ID:1Hgm,项目名称:vscode,代码行数:4,代码来源:modesRegistry.test.ts

示例6: setup

	setup(() => {
		instantiationService= new TestInstantiationService();
		instantiationService.stub(ITelemetryService);
		instantiationService.stub(IModelService, createMockModelService(instantiationService));
	});
开发者ID:Joanlove526,项目名称:vscode,代码行数:5,代码来源:searchResult.test.ts

示例7: suite

suite('SearchResult', () => {

	let instantiationService: TestInstantiationService;

	setup(() => {
		instantiationService= new TestInstantiationService();
		instantiationService.stub(ITelemetryService);
		instantiationService.stub(IModelService, createMockModelService(instantiationService));
	});

	test('Line Match', function () {
		let fileMatch = aFileMatch('folder\\file.txt', null);
		let lineMatch = new Match(fileMatch, 'foo bar', 1, 0, 3);
		assert.equal(lineMatch.text(), 'foo bar');
		assert.equal(lineMatch.range().startLineNumber, 2);
		assert.equal(lineMatch.range().endLineNumber, 2);
		assert.equal(lineMatch.range().startColumn, 1);
		assert.equal(lineMatch.range().endColumn, 4);
	});

	test('Line Match - Remove', function () {
		let fileMatch = aFileMatch('folder\\file.txt', aSearchResult(), ...[{
					preview: 'foo bar',
					lineNumber: 1,
					offsetAndLengths: [[0, 3]]
		}]);
		let lineMatch = fileMatch.matches()[0];
		fileMatch.remove(lineMatch);
		assert.equal(fileMatch.matches().length, 0);
	});

	test('File Match', function () {
		let fileMatch = aFileMatch('folder\\file.txt');
		assert.equal(fileMatch.matches(), 0);
		assert.equal(fileMatch.resource().toString(), 'file:///c%3A/folder/file.txt');
		assert.equal(fileMatch.name(), 'file.txt');

		fileMatch = aFileMatch('file.txt');
		assert.equal(fileMatch.matches(), 0);
		assert.equal(fileMatch.resource().toString(), 'file:///c%3A/file.txt');
		assert.equal(fileMatch.name(), 'file.txt');
	});

	test('Alle Drei Zusammen', function () {
		let searchResult = instantiationService.createInstance(SearchResult, null);
		let fileMatch = aFileMatch('far\\boo', searchResult);
		let lineMatch = new Match(fileMatch, 'foo bar', 1, 0, 3);

		assert(lineMatch.parent() === fileMatch);
		assert(fileMatch.parent() === searchResult);
	});

	test('Adding a raw match will add a file match with line matches', function () {
		let testObject = aSearchResult();
		let target= [aRawMatch('file://c:/', aLineMatch('preview 1', 1, [[1, 3], [4, 7]]), aLineMatch('preview 2'))];

		testObject.add(target);

		assert.equal(3, testObject.count());

		let actual= testObject.matches();
		assert.equal(1, actual.length);
		assert.equal('file://c:/', actual[0].resource().toString());

		let actuaMatches= actual[0].matches();
		assert.equal(3, actuaMatches.length);

		assert.equal('preview 1', actuaMatches[0].text());
		assert.ok(new Range(2, 2, 2, 5).equalsRange(actuaMatches[0].range()));

		assert.equal('preview 1', actuaMatches[1].text());
		assert.ok(new Range(2, 5, 2, 12).equalsRange(actuaMatches[1].range()));

		assert.equal('preview 2', actuaMatches[2].text());
		assert.ok(new Range(2, 1, 2, 2).equalsRange(actuaMatches[2].range()));
	});

	test('Adding multiple raw matches', function () {
		let testObject = aSearchResult();
		let target= [aRawMatch('file://c:/1', aLineMatch('preview 1', 1, [[1, 3], [4, 7]])), aRawMatch('file://c:/2', aLineMatch('preview 2'))];

		testObject.add(target);

		assert.equal(3, testObject.count());

		let actual= testObject.matches();
		assert.equal(2, actual.length);
		assert.equal('file://c:/1', actual[0].resource().toString());

		let actuaMatches= actual[0].matches();
		assert.equal(2, actuaMatches.length);
		assert.equal('preview 1', actuaMatches[0].text());
		assert.ok(new Range(2, 2, 2, 5).equalsRange(actuaMatches[0].range()));
		assert.equal('preview 1', actuaMatches[1].text());
		assert.ok(new Range(2, 5, 2, 12).equalsRange(actuaMatches[1].range()));

		actuaMatches= actual[1].matches();
		assert.equal(1, actuaMatches.length);
		assert.equal('preview 2', actuaMatches[0].text());
		assert.ok(new Range(2, 1, 2, 2).equalsRange(actuaMatches[0].range()));
//.........这里部分代码省略.........
开发者ID:Joanlove526,项目名称:vscode,代码行数:101,代码来源:searchResult.test.ts

示例8: function

	test('Search Model: isReplaceActive return false if no replace text is set', function () {
		let testObject:SearchModel= instantiationService.createInstance(SearchModel);

		assert.ok(!testObject.isReplaceActive());
	});
开发者ID:baltth,项目名称:vscode,代码行数:5,代码来源:searchModel.test.ts

示例9:

	test('Bug 12104: [f12] createModel not successfully handling mime type list?', () => {
		let modeService = instantiationService.createInstance(ModeServiceImpl);
		assert.equal(modeService.getModeId('text/html,text/plain'), 'html');
	});
开发者ID:1Hgm,项目名称:vscode,代码行数:4,代码来源:modesRegistry.test.ts

示例10: aSearchResult

	function aSearchResult(): SearchResult {
		let searchModel = instantiationService.createInstance(SearchModel);
		return searchModel.searchResult;
	}
开发者ID:Joanlove526,项目名称:vscode,代码行数:4,代码来源:searchResult.test.ts


注:本文中的vs/test/utils/instantiationTestUtils.TestInstantiationService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。