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


TypeScript typemoq.Mock类代码示例

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


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

示例1:

const mockEmailQueue = () => {
  const emailMock = TypeMoq.Mock.ofType(EmailQueue);

  emailMock.setup(x => x.addJob(TypeMoq.It.isAny()))
    .returns((): any => null);

  container.rebind<EmailQueueInterface>(EmailQueueType).toConstantValue(emailMock.object);
};
开发者ID:Norestlabs-Mariya,项目名称:backend-ico-dashboard,代码行数:8,代码来源:test.app.factory.ts

示例2: getMockErrorMessageService

function getMockErrorMessageService(deferredPromise: Deferred<{}>): TypeMoq.Mock<ErrorMessageServiceStub> {
	let errorMessageServiceStub = new ErrorMessageServiceStub();
	let mockErrorMessageService = TypeMoq.Mock.ofInstance(errorMessageServiceStub);
	mockErrorMessageService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).callback(() => {
		deferredPromise.resolve(true);
	});
	return mockErrorMessageService;
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:8,代码来源:firewallRuleDialogController.test.ts

示例3: test

	test('getCurrentGlobalConnection returns the connection from OE if there is no active tab, even if OE is not focused', () => {
		let connectionProfile = { databaseName: 'test_database', id: 'test_id', authenticationType: 'SQL Login', password: 'test_password', serverName: 'test_server', userName: 'test_user' } as IConnectionProfile;
		let mockObjectExplorerService = TypeMoq.Mock.ofInstance({ isFocused: () => undefined, getSelectedProfileAndDatabase: () => undefined } as IObjectExplorerService);
		let mockConnectionManagementService = TypeMoq.Mock.ofType(TestConnectionManagementService);
		let mockWorkbenchEditorService = TypeMoq.Mock.ofType(WorkbenchEditorTestService);
		let oeProfile = new ConnectionProfile(undefined, connectionProfile);
		mockObjectExplorerService.setup(x => x.isFocused()).returns(() => false);
		mockObjectExplorerService.setup(x => x.getSelectedProfileAndDatabase()).returns(() => {
			return { profile: oeProfile, databaseName: undefined };
		});
		mockConnectionManagementService.setup(x => x.isProfileConnected(TypeMoq.It.is(profile => profile === oeProfile))).returns(() => true);
		mockWorkbenchEditorService.setup(x => x.getActiveEditorInput()).returns(() => undefined);

		// If I call getCurrentGlobalConnection, it should return the expected profile from OE
		let actualProfile = TaskUtilities.getCurrentGlobalConnection(mockObjectExplorerService.object, mockConnectionManagementService.object, mockWorkbenchEditorService.object);
		assert.equal(actualProfile, oeProfile);
	});
开发者ID:jumpinjackie,项目名称:sqlopsstudio,代码行数:17,代码来源:taskUtilities.test.ts

示例4: test

	test('getSelectedProfileAndDatabase returns undefined when there is no selection', () => {
		let serverTreeView = TypeMoq.Mock.ofInstance({ getSelection: () => undefined, onSelectionOrFocusChange: Event.None } as ServerTreeView);
		serverTreeView.setup(x => x.getSelection()).returns(() => []);
		objectExplorerService.registerServerTreeView(serverTreeView.object);

		let selectedProfileAndDatabase = objectExplorerService.getSelectedProfileAndDatabase();
		assert.equal(selectedProfileAndDatabase, undefined);
	});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:8,代码来源:objectExplorerService.test.ts

示例5: getMockLineNumberTransformer

export function getMockLineNumberTransformer(): IMock<LineColTransformer> {
    const mock = Mock.ofType(LineColTransformer);

    mock.setup(m => m.setBreakpoints(It.isAny()))
        .returns(args => args);

    return mock;
}
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:8,代码来源:transformerMocks.ts

示例6: it

 it('logs info messages', () => {
   const consoleProxy = TypeMoq.Mock.ofType<ConsoleProxy>();
   const consoleSink = new ConsoleSink({ consoleProxy: consoleProxy.object });
   consoleSink.emit([
     new LogEvent('', LogEventLevel.information, new MessageTemplate('Test'))
   ]);
   consoleProxy.verify(m => m.info(TypeMoq.It.isAny()), TypeMoq.Times.once());
 });
开发者ID:Wedvich,项目名称:structured-log,代码行数:8,代码来源:consoleSink.spec.ts

示例7: setup

		setup(() => {

			// Mock ConnectionManagementService but don't set connected state
			memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
			memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
			queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined);
			queryConnectionService.callBase = true;

			// Mock InstantiationService to give us the actions
			queryActionInstantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);

			queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
				return new TPromise((resolve) => resolve(mockEditor));
			});

			queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
				// Default
				return new RunQueryAction(undefined, undefined, undefined);
			});

			// Setup hook to capture calls to create the listDatabase action
			queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
				.returns((definition, editor, action, selectBox) => {
					if (definition.ID === 'listDatabaseQueryActionItem') {
						let item = new ListDatabasesActionItem(editor, action, queryConnectionService.object, undefined, undefined, undefined,configurationService.object);
						return item;
					}
					// Default
					return new RunQueryAction(undefined, undefined, undefined);
				});

			let fileInput = new UntitledEditorInput(URI.parse('testUri'), false, '', '', '', instantiationService.object, undefined, undefined, undefined);
			queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose, undefined, undefined);
			queryModelService.callBase = true;
			queryInput = new QueryInput(
				'',
				fileInput,
				undefined,
				undefined,
				undefined,
				queryModelService.object,
				undefined,
				undefined
			);
		});
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:45,代码来源:queryEditor.test.ts

示例8: it

    it("should stop download on stop command", inject([MainViewComponent], (mainView) => {
        var isCalled = false;
        listDownloaderMock.setup(c => c.stopDownload()).callback(() => isCalled = true);

        mainView.audioList = [];
        mainView.onViewStopClick();

        expect(isCalled).toBe(true,  "stopDownload should be called");
    }));
开发者ID:ip821,项目名称:NodeJsTest,代码行数:9,代码来源:mainview_spec.ts

示例9: it

 it('logs error messages', () => {
   const consoleProxy = TypeMoq.Mock.ofType<ConsoleProxy>();
   const consoleSink = new ConsoleSink({ console: consoleProxy.object });
   consoleSink.emit([
     new LogEvent('', LogEventLevel.fatal, new MessageTemplate('Test')),
     new LogEvent('', LogEventLevel.error, new MessageTemplate('Test'))
   ]);
   consoleProxy.verify(m => m.error(TypeMoq.It.isAny()), TypeMoq.Times.exactly(2));
 });
开发者ID:structured-log,项目名称:structured-log,代码行数:9,代码来源:consoleSink.spec.ts

示例10: test

    test("Logger posts log message to channel", () => {
        let mockChannel = TypeMoq.Mock.ofType<OutputChannel>();
        mockChannel.setup(c => c.appendLine(TypeMoq.It.isAnyString())).verifiable(TypeMoq.Times.once());

        let logger = new Logger(mockChannel.object);
        logger.log("Test message");

        mockChannel.verifyAll();
    });
开发者ID:kindohm,项目名称:vscode-tidalcycles,代码行数:9,代码来源:logger.test.ts


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