public void LatestServer_APICompatibility()
        {
            // Arrange the service used to interact with SQ
            var s          = new SonarQubeServiceWrapper(this.serviceProvider);
            var connection = new ConnectionInformation(new Uri("https://sonarqube.com"));

            // Step 1: Connect anonymously
            ProjectInformation[] projects = null;

            RetryAction(() => s.TryGetProjects(connection, CancellationToken.None, out projects),
                        "Get projects from SonarQube server");
            projects.Should().NotBeEmpty("No projects were returned");

            // Step 2: Get quality profile for the first project
            var            project = projects.FirstOrDefault();
            QualityProfile profile = null;

            RetryAction(() => s.TryGetQualityProfile(connection, project, Language.CSharp, CancellationToken.None, out profile),
                        "Get quality profile from SonarQube server");
            profile.Should().NotBeNull("No quality profile was returned");

            // Step 3: Get quality profile export for the quality profile
            RoslynExportProfile export = null;

            RetryAction(() => s.TryGetExportProfile(connection, profile, Language.CSharp, CancellationToken.None, out export),
                        "Get quality profile export from SonarQube server");
            export.Should().NotBeNull("No quality profile export was returned");

            // Errors are logged to output window pane and we don't expect any
            this.outputWindowPane.AssertOutputStrings(0);
        }
Esempio n. 2
0
        bool ISonarQubeServiceWrapper.TryGetExportProfile(ConnectionInformation serverConnection, QualityProfile profile, Language language, CancellationToken token, out RoslynExportProfile export)
        {
            this.AssertExpectedConnection(serverConnection);

            profile.Should().NotBeNull("QualityProfile is expected");

            this.GetExportAction?.Invoke();

            export = null;
            this.ReturnExport.TryGetValue(profile, out export);

            QualityProfile profile2;

            this.ReturnProfile.TryGetValue(language, out profile2);
            profile.Should().Be(profile2, "Unexpected profile for language");

            return(export != null);
        }