• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript autoOAuthDialogController.AutoOAuthDialogController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: suite

suite('auto OAuth dialog controller tests', () => {
	let instantiationService: TypeMoq.Mock<InstantiationService>;
	let mockAutoOAuthDialog: TypeMoq.Mock<AutoOAuthDialog>;
	let mockAccountManagementService: TypeMoq.Mock<AccountManagementTestService>;
	let mockErrorMessageService: TypeMoq.Mock<ErrorMessageServiceStub>;
	let autoOAuthDialogController: AutoOAuthDialogController;

	let mockOnCancelEvent: Emitter<void>;
	let mockOnAddAccountEvent: Emitter<void>;
	let mockOnCloseEvent: Emitter<void>;

	let providerId = 'azure';
	let title = 'Add Account';
	let message = 'This is the dialog description';
	let userCode = 'abcde';
	let uri = 'uri';

	setup(() => {
		mockOnCancelEvent = new Emitter<void>();
		mockOnAddAccountEvent = new Emitter<void>();
		mockOnCloseEvent = new Emitter<void>();

		// Create a mock auto OAuth dialog
		let autoOAuthDialog = new AutoOAuthDialog(null, null, null, null, new ContextKeyServiceStub());
		mockAutoOAuthDialog = TypeMoq.Mock.ofInstance(autoOAuthDialog);

		mockAutoOAuthDialog.setup(x => x.onCancel).returns(() => mockOnCancelEvent.event);
		mockAutoOAuthDialog.setup(x => x.onHandleAddAccount).returns(() => mockOnAddAccountEvent.event);
		mockAutoOAuthDialog.setup(x => x.onCloseEvent).returns(() => mockOnCloseEvent.event);
		mockAutoOAuthDialog.setup(x => x.render());
		mockAutoOAuthDialog.setup(x => x.open(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()));
		mockAutoOAuthDialog.setup(x => x.close()).callback(() => {
			mockOnCloseEvent.fire();
		});

		// Create a mocked out instantiation service
		instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Strict);
		instantiationService.setup(x => x.createInstance(TypeMoq.It.isValue(AutoOAuthDialog)))
			.returns(() => mockAutoOAuthDialog.object);


		// Create a mocked account management service
		let accountManagementTestService = new AccountManagementTestService();
		mockAccountManagementService = TypeMoq.Mock.ofInstance(accountManagementTestService);
		mockAccountManagementService.setup(x => x.copyUserCodeAndOpenBrowser(TypeMoq.It.isAny(), TypeMoq.It.isAny()));

		// Create a mocked error message service
		let errorMessageServiceStub = new ErrorMessageServiceStub();
		mockErrorMessageService = TypeMoq.Mock.ofInstance(errorMessageServiceStub);
		mockErrorMessageService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()));

		// Create a mocked auto OAuth dialog controller
		autoOAuthDialogController = new AutoOAuthDialogController(instantiationService.object, mockAccountManagementService.object, mockErrorMessageService.object);

	});

	test('Open auto OAuth when the flyout is already open, return an error', () => {

		// If: Open auto OAuth dialog first time
		autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);

		// Then: It should open the flyout successfully
		mockAutoOAuthDialog.verify(x => x.open(title, message, userCode, uri), TypeMoq.Times.once());
		mockErrorMessageService.verify(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.never());

		// If: a oauth flyout is already open
		autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);

		// Then: An error dialog should have been opened
		mockErrorMessageService.verify(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.once());
	});

	test('Close auto OAuth dialog successfully', () => {
		let title = 'Add Account';
		let message = 'This is the dialog description';
		let userCode = 'abcde';
		let uri = 'uri';

		autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);

		// If: closeAutoOAuthDialog is called
		autoOAuthDialogController.closeAutoOAuthDialog();

		// Then: it should close the dialog
		mockAutoOAuthDialog.verify(x => x.close(), TypeMoq.Times.once());
	});

	test('Open and close auto OAuth dialog multiple times should work properly', () => {
		let title = 'Add Account';
		let message = 'This is the dialog description';
		let userCode = 'abcde';
		let uri = 'uri';

		autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);
		autoOAuthDialogController.closeAutoOAuthDialog();

		// If: Open the flyout second time
		autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);

		// Then: It should open the flyout twice successfully
//.........这里部分代码省略.........
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:101,代码来源:autoOAuthDialogController.test.ts


示例2:

	test('Close auto OAuth dialog successfully', () => {
		let title = 'Add Account';
		let message = 'This is the dialog description';
		let userCode = 'abcde';
		let uri = 'uri';

		autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);

		// If: closeAutoOAuthDialog is called
		autoOAuthDialogController.closeAutoOAuthDialog();

		// Then: it should close the dialog
		mockAutoOAuthDialog.verify(x => x.close(), TypeMoq.Times.once());
	});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:14,代码来源:autoOAuthDialogController.test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap