private bool IsServerPluginSupported(ServerPlugin[] plugins, MinimumSupportedServerPlugin minimumSupportedPlugin) { var plugin = plugins.FirstOrDefault(x => StringComparer.Ordinal.Equals(x.Key, minimumSupportedPlugin.Key)); var isPluginSupported = !string.IsNullOrWhiteSpace(plugin?.Version) && VersionHelper.Compare(plugin.Version, minimumSupportedPlugin.MinimumVersion) >= 0; var pluginSupportMessageFormat = string.Format(Strings.SubTextPaddingFormat, isPluginSupported ? Strings.SupportedPluginFoundMessage : Strings.UnsupportedPluginFoundMessage); VsShellUtils.WriteToSonarLintOutputPane(this.host, pluginSupportMessageFormat, minimumSupportedPlugin.ToString()); return(isPluginSupported); }
private void ConnectionWorkflow_ConnectionStep_WhenXPluginAndNoXProject_AbortsWorkflowAndDisconnects(string projectName, string projectKind, MinimumSupportedServerPlugin minimumSupportedServerPlugin) { // Arrange var connectionInfo = new ConnectionInformation(new Uri("http://server")); var projects = new ProjectInformation[] { new ProjectInformation { Key = "project1" } }; this.sonarQubeService.ReturnProjectInformation = projects; this.sonarQubeService.ClearServerPlugins(); this.sonarQubeService.RegisterServerPlugin(new ServerPlugin { Key = minimumSupportedServerPlugin.Key, Version = minimumSupportedServerPlugin.MinimumVersion }); this.projectSystemHelper.Projects = new[] { new ProjectMock(projectName) { ProjectKind = projectKind } }; bool projectChangedCallbackCalled = false; this.host.TestStateManager.SetProjectsAction = (c, p) => { projectChangedCallbackCalled = true; Assert.AreSame(connectionInfo, c, "Unexpected connection"); CollectionAssert.AreEqual(projects, p.ToArray(), "Unexpected projects"); }; var controller = new ConfigurableProgressController(); var executionEvents = new ConfigurableProgressStepExecutionEvents(); string connectionMessage = connectionInfo.ServerUri.ToString(); var testSubject = new ConnectionWorkflow(this.host, new RelayCommand(AssertIfCalled)); ConfigurableUserNotification notifications = (ConfigurableUserNotification)this.host.ActiveSection.UserNotifications; // Act testSubject.ConnectionStep(controller, CancellationToken.None, connectionInfo, executionEvents); // Verify controller.AssertNumberOfAbortRequests(1); executionEvents.AssertProgressMessages( connectionInfo.ServerUri.ToString(), Strings.DetectingServerPlugins, Strings.ConnectionResultFailure); Assert.IsFalse(projectChangedCallbackCalled, "ConnectedProjectsCallaback was called"); notifications.AssertNotification(NotificationIds.BadServerPluginId, string.Format(Strings.OnlySupportedPluginHasNoProjectInSolution, minimumSupportedServerPlugin.Language.Name)); }