當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Mock.ofType方法代碼示例

本文整理匯總了TypeScript中typemoq.Mock.ofType方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Mock.ofType方法的具體用法?TypeScript Mock.ofType怎麽用?TypeScript Mock.ofType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在typemoq.Mock的用法示例。


在下文中一共展示了Mock.ofType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: buildApp

export const testAppForInitiateLogin = () => {
  const verifyMock = TypeMoq.Mock.ofType(VerificationClient);
  const authMock = TypeMoq.Mock.ofType(AuthClient);

  const initiateResult: InitiateResult = {
    status: 200,
    verificationId: '123',
    attempts: 0,
    expiredOn: 124545,
    method: 'email'
  };

  const loginResult: AccessTokenResponse = {
    accessToken: 'token'
  };

  verifyMock.setup(x => x.initiateVerification(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
    .returns(async(): Promise<InitiateResult> => initiateResult);

  authMock.setup(x => x.loginUser(TypeMoq.It.isAny()))
    .returns(async(): Promise<AccessTokenResponse> => loginResult);

  container.rebind<VerificationClientInterface>(VerificationClientType).toConstantValue(verifyMock.object);
  container.rebind<AuthClientInterface>(AuthClientType).toConstantValue(authMock.object);
  return buildApp();
};
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:26,代碼來源:test.app.factory.ts

示例2: test

	test('ManageConnectionAction - test if connect is called for manage action if not already connected', (done) => {
		let isConnectedReturnValue: boolean = false;
		let connection: ConnectionProfile = new ConnectionProfile(capabilitiesService, {
			connectionName: 'Test',
			savePassword: false,
			groupFullName: 'testGroup',
			serverName: 'testServerName',
			databaseName: 'testDatabaseName',
			authenticationType: 'integrated',
			password: 'test',
			userName: 'testUsername',
			groupId: undefined,
			providerName: 'MSSQL',
			options: {},
			saveProfile: true,
			id: 'testId'
		});
		let connectionManagementService = createConnectionManagementService(isConnectedReturnValue, connection);
		let objectExplorerService = createObjectExplorerService(connectionManagementService.object, undefined);
		let treeSelectionMock = TypeMoq.Mock.ofType(TreeSelectionHandler);
		let instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
		instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
			return treeSelectionMock.object;
		});

		let manageConnectionAction: ManageConnectionAction = new ManageConnectionAction(ManageConnectionAction.ID,
			ManageConnectionAction.LABEL, undefined, connectionManagementService.object, capabilitiesService, instantiationService.object, objectExplorerService.object);

		var actionContext = new ObjectExplorerActionsContext();
		actionContext.connectionProfile = connection.toIConnectionProfile();
		actionContext.isConnectionNode = true;
		manageConnectionAction.run(actionContext).then((value) => {
			connectionManagementService.verify(x => x.connect(TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny(), undefined), TypeMoq.Times.once());
		}).then(() => done(), (err) => done(err));
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:35,代碼來源:connectionTreeActions.test.ts

示例3: beforeEach

 beforeEach(() => {
     holder = {};
     projectionRunner = Mock.ofType(MockProjectionRunner);
     holder["Mock"] = projectionRunner.object;
     request = new MockRequest();
     response = Mock.ofType<IResponse>();
 });
開發者ID:tierratelematics,項目名稱:prettygoat,代碼行數:7,代碼來源:ProjectionsHandlerSpec.ts

示例4: test

	test('getCurrentGlobalConnection returns the connection from the active tab, if there is one and 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);
		let connectionProfile2 = Object.assign({}, connectionProfile);
		connectionProfile2.serverName = 'test_server_2';
		connectionProfile2.id = 'test_id_2';
		let tabProfile = new ConnectionProfile(undefined, connectionProfile2);
		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 || profile === tabProfile))).returns(() => true);

		// Mock the workbench service to return the active tab connection
		let tabConnectionUri = 'test_uri';
		let editorInput = new UntitledEditorInput(URI.parse(tabConnectionUri), false, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
		let queryInput = new QueryInput(undefined, undefined, editorInput, undefined, undefined, undefined, undefined, undefined);
		mockWorkbenchEditorService.setup(x => x.getActiveEditorInput()).returns(() => queryInput);
		mockConnectionManagementService.setup(x => x.getConnectionProfile(tabConnectionUri)).returns(() => tabProfile);

		// If I call getCurrentGlobalConnection, it should return the expected profile from the active tab
		let actualProfile = TaskUtilities.getCurrentGlobalConnection(mockObjectExplorerService.object, mockConnectionManagementService.object, mockWorkbenchEditorService.object);
		assert.equal(actualProfile.databaseName, tabProfile.databaseName);
		assert.equal(actualProfile.authenticationType, tabProfile.authenticationType);
		assert.equal(actualProfile.password, tabProfile.password);
		assert.equal(actualProfile.serverName, tabProfile.serverName);
		assert.equal(actualProfile.userName, tabProfile.userName);
	});
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:31,代碼來源:taskUtilities.test.ts

示例5: it

 it('queues events if a flush is in progress', () => {
   let emittedEvents = [];
   const pipeline = new Pipeline();
   const pipelineStage1 = TypeMoq.Mock.ofType<PipelineStage>();
   const pipelineStage2 = TypeMoq.Mock.ofType<PipelineStage>();
   pipelineStage1.setup(m => m.emit(TypeMoq.It.isAny())).returns(events => events);
   pipelineStage1.setup(m => m.flush()).returns(() => new Promise(resolve => setTimeout(resolve, 1)));
   pipelineStage2.setup(m => m.emit(TypeMoq.It.isAny())).callback(events => emittedEvents = emittedEvents.concat(events));
   pipelineStage2.setup(m => m.flush()).returns(() => Promise.resolve());
   pipeline.addStage(pipelineStage1.object);
   pipeline.addStage(pipelineStage2.object);
   const events = [
     new LogEvent('', LogEventLevel.information, new MessageTemplate('Message 1'), {}),
     new LogEvent('', LogEventLevel.information, new MessageTemplate('Message 2'), {}),
     new LogEvent('', LogEventLevel.information, new MessageTemplate('Message 3'), {}),
     new LogEvent('', LogEventLevel.information, new MessageTemplate('Message 4'), {})
   ];
   
   return pipeline.emit(events.slice(0, 2))
     .then(() => {
       expect(emittedEvents).to.have.length(2);
       expect(emittedEvents[0]).to.have.deep.property('messageTemplate.raw', 'Message 1');
       expect(emittedEvents[1]).to.have.deep.property('messageTemplate.raw', 'Message 2');
     })
     .then(() => Promise.all([pipeline.flush(), pipeline.emit(events.slice(2))]))
     .then(() => {
       expect(emittedEvents).to.have.length(4);
       expect(emittedEvents[2]).to.have.deep.property('messageTemplate.raw', 'Message 3');
       expect(emittedEvents[3]).to.have.deep.property('messageTemplate.raw', 'Message 4');
     });
 });
開發者ID:Wedvich,項目名稱:structured-log,代碼行數:31,代碼來源:pipeline.spec.ts

示例6: beforeEach

 beforeEach(() => {
     factory = Mock.ofType<IViewModelFactory>();
     uriResolver = Mock.ofType<IUriResolver>();
     viewResolver = Mock.ofType<IViewResolver>();
     serializer = Mock.ofType<ISerializer<Dictionary<string>,string>>();
     subject = new ContextFactory(uriResolver.object, viewResolver.object, factory.object, serializer.object);
 });
開發者ID:tierratelematics,項目名稱:ninjagoat,代碼行數:7,代碼來源:ContextFactorySpec.ts

示例7: mockEmailQueue

export const testAppForVerifyLogin = () => {
  mockEmailQueue();

  const authMock = TypeMoq.Mock.ofType(AuthClient);

  const verifyTokenResultNotVerified = {
    login: 'activated@test.com'
  };

  authMock.setup(x => x.verifyUserToken(TypeMoq.It.isValue('not_verified_token')))
    .returns(async(): Promise<any> => verifyTokenResultNotVerified);

  const verifyMock = TypeMoq.Mock.ofType(VerificationClient);

  const initiateResult: InitiateResult = {
    status: 200,
    verificationId: '123',
    attempts: 0,
    expiredOn: 124545,
    method: 'email'
  };

  verifyMock.setup(x => x.initiateVerification(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
    .returns(async(): Promise<InitiateResult> => initiateResult);

  container.rebind<VerificationClientInterface>(VerificationClientType).toConstantValue(verifyMock.object);
  container.rebind<AuthClientInterface>(AuthClientType).toConstantValue(authMock.object);
  return buildApp();
};
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:29,代碼來源:test.app.factory.ts

示例8: beforeEach

 beforeEach(() => {
     registry = Mock.ofType<IViewModelRegistry>();
     componentFactory = Mock.ofType<IPageComponentFactory>();
     componentFactory.setup(c => c.componentForUri(It.isAny())).returns(() => null);
     componentFactory.setup(c => c.componentForMaster()).returns(() => null);
     componentFactory.setup(c => c.componentForNotFound()).returns(() => null);
     subject = new RoutingAdapter(registry.object, componentFactory.object, null);
 });
開發者ID:tierratelematics,項目名稱:ninjagoat,代碼行數:8,代碼來源:RoutingAdapterSpec.ts

示例9: beforeEach

 beforeEach(() => {
     client = Mock.ofType<ISocketClient>();
     registry = Mock.ofType<IProjectionRegistry>();
     subject = new ClientRegistry(registry.object);
     let projection = new ClientRegistryDefinition().define();
     registry.setup(r => r.projectionFor("Foo", "Admin")).returns(() => ["Admin", projection]);
     registry.setup(r => r.projectionFor("Bar", "Admin")).returns(() => ["Admin", projection]);
     registry.setup(r => r.projectionFor("KeyUndefined", "Admin")).returns(() => ["Admin", projection]);
 });
開發者ID:tierratelematics,項目名稱:prettygoat,代碼行數:9,代碼來源:ClientRegistrySpec.ts

示例10: beforeEach

 beforeEach(() => {
     let filter = Mock.ofType<IIdempotenceFilter>();
     filter.setup(f => f.serialize()).returns(() => [
         {id: "test", timestamp: new Date(2)}
     ]);
     mementoProducer = Mock.ofType<IMementoProducer<any>>();
     subject = new SnapshotProducer({
         "Mock": filter.object
     }, mementoProducer.object);
 });
開發者ID:tierratelematics,項目名稱:prettygoat,代碼行數:10,代碼來源:SnapshotProducerSpec.ts

示例11: beforeEach

 beforeEach(() => {
     requestHandler = Mock.ofType<IRequestHandler>();
     routeResolver = Mock.ofType<IRouteResolver>();
     request = new MockRequest();
     request.method = "GET";
     request.originalRequest = undefined;
     response = Mock.ofType<IResponse>();
     response.setup(r => r.status(anyValue)).returns(() => response.object);
     subject = new RequestAdapter(routeResolver.object);
 });
開發者ID:tierratelematics,項目名稱:prettygoat,代碼行數:10,代碼來源:RequestAdapterSpec.ts

示例12: beforeEach

 beforeEach(() => {
     registry = Mock.ofType<IProjectionRegistry>();
     request = new MockRequest();
     response = Mock.ofType<IResponse>();
     subject = new ProjectionsListHandler(registry.object);
     registry.setup(r => r.projections()).returns(() => [
         ["Admin", {name: "Test", definition: {}, publish: {}}],
         ["Admin", {name: "Test2", definition: {}, publish: {}}]
     ]);
 });
開發者ID:tierratelematics,項目名稱:prettygoat,代碼行數:10,代碼來源:ProjectionsListSpec.ts

示例13: it

 it('catches errors when suppressed', () => {
   let loggedEvents = [];
   const mockPipeline = TypeMoq.Mock.ofType<Pipeline>();
   const logger = new Logger(TypeMoq.Mock.ofType<Pipeline>().object);
   expect(() => logger.fatal(undefined)).to.not.throw();
   expect(() => logger.error(undefined)).to.not.throw();
   expect(() => logger.warn(undefined)).to.not.throw();
   expect(() => logger.info(undefined)).to.not.throw();
   expect(() => logger.debug(undefined)).to.not.throw();
   expect(() => logger.verbose(undefined)).to.not.throw();
 });
開發者ID:structured-log,項目名稱:structured-log,代碼行數:11,代碼來源:logger.spec.ts

示例14: beforeEach

 beforeEach(() => {
     projectionRunner = Mock.ofType(MockProjectionRunner);
     dateRetriever = Mock.ofType<IDateRetriever>();
     holder = {};
     holder["projection"] = projectionRunner.object;
     request = new MockRequest();
     response = Mock.ofType<IResponse>();
     response.setup(s => s.status(It.isAny())).returns(a => response.object);
     snapshotRepository = Mock.ofType<ISnapshotRepository>();
     snapshotRepository.setup(s => s.saveSnapshot(It.isAny(), It.isAny())).returns(() => Promise.resolve());
     snapshotRepository.setup(s => s.deleteSnapshot(It.isAny())).returns(() => Promise.resolve());
 });
開發者ID:tierratelematics,項目名稱:prettygoat,代碼行數:12,代碼來源:SnapshotHandlerSpec.ts

示例15: beforeEach

 beforeEach(() => {
     locationNavigator = TypeMoq.Mock.ofType(MockLocationNavigator);
     settingsManager = TypeMoq.Mock.ofType(MockSettingsManager);
     subject = new Auth0Provider({
         clientNamespace: "test.auth0.com",
         logoutCallbackUrl: "http://localhost",
         loginCallbackUrl: "http://localhost",
         renewCallbackUrl: "http://localhost",
         clientId: "test",
         audience: "test-audience"
     }, settingsManager.object, locationNavigator.object);
 });
開發者ID:tierratelematics,項目名稱:ninjagoat-auth,代碼行數:12,代碼來源:AuthProviderSpec.ts


注:本文中的typemoq.Mock.ofType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。