Beispiel #1
0
        public void QualityProfileBackgroundProcessor_BackgroundTask_SameTimestampDifferentProfile_RequiresUpdate()
        {
            // Setup
            string qpKey       = "Profile1";
            var    testSubject = this.GetTestSubject();

            this.SetFilteredProjects(Language.CSharp, Language.CSharp);
            this.bindingSerializer.CurrentBinding = new BoundSonarQubeProject
            {
                ServerUri  = new Uri("http://server"),
                ProjectKey = "ProjectKey",
                Profiles   = new Dictionary <Language, ApplicableQualityProfile>()
            };
            DateTime sameTimestamp = DateTime.Now;

            this.bindingSerializer.CurrentBinding.Profiles[Language.CSharp] = new ApplicableQualityProfile
            {
                ProfileKey       = SonarQubeServiceWrapper.GetServerLanguageKey(Language.CSharp) + "Old", // Different profile key
                ProfileTimestamp = sameTimestamp
            };
            this.ConfigureValidSonarQubeServiceWrapper(this.bindingSerializer.CurrentBinding, sameTimestamp, qpKey, Language.CSharp);

            // Act + Verify
            VerifyBackgroundExecution(true, testSubject,
                                      Strings.SonarLintProfileCheck,
                                      Strings.SonarLintProfileCheckDifferentProfile);
        }
        private static QualityProfile CreateRandomQualityProfile(Language language, bool isDefault = false)
        {
            var languageKey = SonarQubeServiceWrapper.GetServerLanguageKey(language);

            return(new QualityProfile {
                Key = Guid.NewGuid().ToString("N"), Language = languageKey, IsDefault = isDefault
            });
        }
Beispiel #3
0
        private QualityProfile ConfigureProfileExport(RoslynExportProfile export, Language language)
        {
            var profile = new QualityProfile {
                Language = SonarQubeServiceWrapper.GetServerLanguageKey(language)
            };

            this.sonarQubeService.ReturnProfile[language] = profile;
            this.sonarQubeService.ReturnExport[profile]   = export;

            return(profile);
        }
Beispiel #4
0
        private void ConfigureValidSonarQubeServiceWrapper(BoundSonarQubeProject binding, DateTime?timestamp, string qualityProfileKey, params Language[] expectedLanguageProfiles)
        {
            var sqService = new ConfigurableSonarQubeServiceWrapper();

            this.host.SonarQubeService = sqService;

            sqService.AllowConnections   = true;
            sqService.ExpectedConnection = binding.CreateConnectionInformation();
            sqService.ExpectedProjectKey = binding.ProjectKey;

            foreach (Language language in expectedLanguageProfiles)
            {
                sqService.ReturnProfile[language] = new QualityProfile
                {
                    Key      = qualityProfileKey,
                    Language = SonarQubeServiceWrapper.GetServerLanguageKey(language),
                    QualityProfileTimestamp = timestamp
                };
            }
        }
Beispiel #5
0
        public void QualityProfileBackgroundProcessor_BackgroundTask_ServiceErrors_DoesNotRequireUpdate()
        {
            // Setup
            var testSubject = this.GetTestSubject();

            this.SetFilteredProjects(Language.VBNET, Language.VBNET);
            this.bindingSerializer.CurrentBinding = new BoundSonarQubeProject
            {
                ServerUri  = new Uri("http://server"),
                ProjectKey = "ProjectKey",
                Profiles   = new Dictionary <Language, ApplicableQualityProfile>()
            };
            this.bindingSerializer.CurrentBinding.Profiles[Language.VBNET] = new ApplicableQualityProfile
            {
                ProfileKey       = SonarQubeServiceWrapper.GetServerLanguageKey(Language.VBNET),
                ProfileTimestamp = DateTime.Now
            };
            this.ConfigureSonarQubeServiceWrapperWithServiceError();

            // Act + Verify
            VerifyBackgroundExecution(false, testSubject,
                                      Strings.SonarLintProfileCheck,
                                      Strings.SonarLintProfileCheckFailed);
        }