/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); // An remember the package. Instance = this; // Register the command handlers. CloudExplorerCommand.Initialize(this); ManageAccountsCommand.Initialize(this); PublishProjectMainMenuCommand.Initialize(this); PublishProjectContextMenuCommand.Initialize(this); LogsViewerToolWindowCommand.Initialize(this); GenerateConfigurationContextMenuCommand.Initialize(this); ErrorReportingToolWindowCommand.Initialize(this); // Activity log utils, to aid in debugging. ActivityLogUtils.Initialize(this); ActivityLogUtils.LogInfo("Starting Google Cloud Tools."); _dteInstance = (DTE)Package.GetGlobalService(typeof(DTE)); VsVersion = _dteInstance.Version; VsEdition = _dteInstance.Edition; // Update the installation status of the package. CheckInstallationStatus(); // Ensure the commands UI state is updated when the GCP project changes. CredentialsStore.Default.Reset += (o, e) => ShellUtils.InvalidateCommandsState(); CredentialsStore.Default.CurrentProjectIdChanged += (o, e) => ShellUtils.InvalidateCommandsState(); }
public void TestRegisterCommand() { LogsViewerToolWindowCommand.Initialize(PackageMock.Object); _menuCommandServiceMock.Verify( s => s.AddCommand( It.Is((MenuCommand c) => c.CommandID.Equals(LogsViewerToolWindowCommand.MenuCommandID))), Times.Once); }
public async Task TestRegisterCommand() { await LogsViewerToolWindowCommand.InitializeAsync(PackageMock.Object, CancellationToken.None); _menuCommandServiceMock.Verify( s => s.AddCommand( It.Is((MenuCommand c) => c.CommandID.Equals(LogsViewerToolWindowCommand.MenuCommandID))), Times.Once); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); // An remember the package. Instance = this; // Register the command handlers. CloudExplorerCommand.Initialize(this); ManageAccountsCommand.Initialize(this); PublishProjectMainMenuCommand.Initialize(this); PublishProjectContextMenuCommand.Initialize(this); LogsViewerToolWindowCommand.Initialize(this); GenerateConfigurationContextMenuCommand.Initialize(this); ErrorReportingToolWindowCommand.Initialize(this); // Activity log utils, to aid in debugging. ActivityLogUtils.Initialize(this); ActivityLogUtils.LogInfo("Starting Google Cloud Tools."); _dteInstance = (DTE)GetService(typeof(DTE)); VsVersion = _dteInstance.Version; VsEdition = _dteInstance.Edition; // Update the installation status of the package. CheckInstallationStatus(); // Ensure the commands UI state is updated when the GCP project changes. CredentialsStore.Default.Reset += (o, e) => ShellUtils.InvalidateCommandsState(); CredentialsStore.Default.CurrentProjectIdChanged += (o, e) => ShellUtils.InvalidateCommandsState(); // With this setting we allow more concurrent connections from each HttpClient instance created // in the process. This will allow all GCP API services to have more concurrent connections with // GCP servers. The first benefit of this is that we can upload more concurrent files to GCS. ServicePointManager.DefaultConnectionLimit = MaximumConcurrentConnections; ExportProvider mefExportProvider = GetService <SComponentModel, IComponentModel>().DefaultExportProvider; _shellUtilsLazy = mefExportProvider.GetExport <IShellUtils>(); _gcpOutputWindowLazy = mefExportProvider.GetExport <IGcpOutputWindow>(); _processService = mefExportProvider.GetExport <IProcessService>(); _statusbarService = mefExportProvider.GetExport <IStatusbarService>(); _userPromptService = mefExportProvider.GetExport <IUserPromptService>(); }
public void TestExecuteCommand() { MenuCommand command = null; _menuCommandServiceMock.Setup( s => s.AddCommand(It.IsAny <MenuCommand>())).Callback((MenuCommand c) => command = c); Mock <IVsWindowFrame> frameMock = VsWindowFrameMocks.GetWindowFrameMock(MockBehavior.Loose); PackageMock.Setup(p => p.FindToolWindow <LogsViewerToolWindow>(false, It.IsAny <int>())) .Returns(() => null); var logsViewerToolWindow = Mock.Of <LogsViewerToolWindow>(); logsViewerToolWindow.Frame = frameMock.Object; PackageMock.Setup(p => p.FindToolWindow <LogsViewerToolWindow>(true, It.IsAny <int>())) .Returns(logsViewerToolWindow); LogsViewerToolWindowCommand.Initialize(PackageMock.Object); command.Invoke(); frameMock.Verify(f => f.Show()); }
public async Task TestExecuteCommand() { MenuCommand command = null; _menuCommandServiceMock.Setup( s => s.AddCommand(It.IsAny <MenuCommand>())).Callback((MenuCommand c) => command = c); Mock <IVsWindowFrame> frameMock = VsWindowFrameMocks.GetWindowFrameMock(); PackageMock.Setup(p => p.FindToolWindow <LogsViewerToolWindow>(false, It.IsAny <int>())).Returns(() => null); var logsViewerToolWindow = Mock.Of <LogsViewerToolWindow>(); logsViewerToolWindow.Frame = frameMock.Object; PackageMock.Setup(p => p.FindToolWindow <LogsViewerToolWindow>(true, It.IsAny <int>())) .Returns(logsViewerToolWindow); await LogsViewerToolWindowCommand.InitializeAsync(PackageMock.Object, CancellationToken.None); command.Invoke(); frameMock.Verify(f => f.Show()); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async Task InitializeAsync(CancellationToken token, IProgress <ServiceProgressData> progress) { try { _componentModel = await GetServiceAsync <SComponentModel, IComponentModel>(); CredentialsStore = _componentModel.GetService <ICredentialsStore>(); ExportProvider mefExportProvider = _componentModel.DefaultExportProvider; _shellUtilsLazy = mefExportProvider.GetExport <IShellUtils>(); _gcpOutputWindowLazy = mefExportProvider.GetExport <IGcpOutputWindow>(); _processService = mefExportProvider.GetExport <IProcessService>(); _statusbarService = mefExportProvider.GetExport <IStatusbarService>(); _userPromptService = mefExportProvider.GetExport <IUserPromptService>(); _dataSourceFactory = mefExportProvider.GetExport <IDataSourceFactory>(); Dte = await GetServiceAsync <SDTE, DTE2>(); // Remember the package. Instance = this; // Activity log utils, to aid in debugging. IVsActivityLog activityLog = await GetServiceAsync <SVsActivityLog, IVsActivityLog>(); await activityLog.LogInfoAsync("Starting Google Cloud Tools."); // Register the command handlers. await Task.WhenAll( CloudExplorerCommand.InitializeAsync(this, token), ManageAccountsCommand.InitializeAsync(this, token), PublishProjectMainMenuCommand.InitializeAsync(this, token), PublishProjectContextMenuCommand.InitializeAsync(this, token), LogsViewerToolWindowCommand.InitializeAsync(this, token), GenerateConfigurationContextMenuCommand.InitializeAsync(this, token), ErrorReportingToolWindowCommand.InitializeAsync(this, token)); // Update the installation status of the package. await CheckInstallationStatusAsync(); // Ensure the commands UI state is updated when the GCP project changes. CredentialsStore.CurrentProjectIdChanged += (o, e) => ShellUtils.InvalidateCommandsState(); // With this setting we allow more concurrent connections from each HttpClient instance created // in the process. This will allow all GCP API services to have more concurrent connections with // GCP servers. The first benefit of this is that we can upload more concurrent files to GCS. ServicePointManager.DefaultConnectionLimit = MaximumConcurrentConnections; IVsRegisterUIFactories registerUIFactories = await GetServiceAsync <SVsUIFactory, IVsRegisterUIFactories>(); var controlFactory = _componentModel.GetService <GcpMenuBarControlFactory>(); await registerUIFactories.RegisterUIFactoryAsync(controlFactory, token); } catch (Exception e) { IVsActivityLog activityLog = await GetServiceAsync <SVsActivityLog, IVsActivityLog>(); await activityLog.LogErrorAsync(e.Message); await activityLog.LogErrorAsync(e.StackTrace); } }