當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。