Ejemplo n.º 1
0
        public void ReadsSettings_IgnoreHeaderComments(string language, string sonarLintXmlPath, bool expectedIgnoreHeaderComments)
        {
            var utilityAnalyzer = new TestUtilityAnalyzer(language, sonarLintXmlPath, DefaultSonarProjectConfig);

            utilityAnalyzer.TestIgnoreHeaderComments.Should().Be(expectedIgnoreHeaderComments);
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue();
        }
Ejemplo n.º 2
0
        public void ReadsSettings_AnalyzeGenerated(string language, string sonarLintXmlPath, bool expectedAnalyzeGeneratedCodeValue)
        {
            var utilityAnalyzer = new TestUtilityAnalyzer(language, sonarLintXmlPath, DefaultSonarProjectConfig);

            utilityAnalyzer.TestAnalyzeGeneratedCode.Should().Be(expectedAnalyzeGeneratedCodeValue);
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue();
        }
Ejemplo n.º 3
0
        public void ReadConfig_OutPath_FromSonarProjectConfig_HasPriority(string firstFile, string secondFile)
        {
            // We do not test what is read from the SonarLint file, but we need it
            var utilityAnalyzer = new TestUtilityAnalyzer(LanguageNames.CSharp, @"ResourceTests\SonarLint.xml", firstFile, secondFile);

            utilityAnalyzer.TestOutPath.Should().Be(@"C:\foo\bar\.sonarqube\out\0\output-cs");
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue();
        }
Ejemplo n.º 4
0
        public void ReadConfig_OutPath(string language, string additionalPath, string expectedOutPath)
        {
            // We do not test what is read from the SonarLint file, but we need it
            var utilityAnalyzer = new TestUtilityAnalyzer(language, @"ResourceTests\SonarLint.xml", additionalPath);

            utilityAnalyzer.TestOutPath.Should().Be(expectedOutPath);
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue();
        }
Ejemplo n.º 5
0
        public void UtilityAnalyzerBase_NoOutputPath_AnalyzerNotEnabled()
        {
            var sonarLintFile   = CreateMockAdditionalText(DUMMY_TEXT, "ResourceTests\\AnalyzeGeneratedTrue\\SonarLint.xml");
            var analyzerOptions = new AnalyzerOptions(ImmutableArray.Create(sonarLintFile.Object));

            // Act
            var utilityAnalyzer = new TestUtilityAnalyzer();

            utilityAnalyzer.TestReadParameters(analyzerOptions, LanguageNames.CSharp);

            // Assert
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeFalse();
        }
Ejemplo n.º 6
0
        public void UtilityAnalyzerBase_NoSonarLintXml_AnalyzerNotEnabled()
        {
            var projectOutputFile = CreateMockAdditionalText(DUMMY_TEXT, "ResourceTests\\ProjectOutFolderPath.txt");
            var analyzerOptions   = new AnalyzerOptions(ImmutableArray.Create(projectOutputFile.Object));

            // Act
            var utilityAnalyzer = new TestUtilityAnalyzer();

            utilityAnalyzer.TestReadParameters(analyzerOptions, LanguageNames.CSharp);

            // Assert
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeFalse();
        }
Ejemplo n.º 7
0
        public void UtilityAnalyzerBase_ReadsSettings_AnalyzeGenerated(string language, string sonarLintXmlPath, bool expectedAnalyzeGeneratedCodeValue)
        {
            var sonarLintFile     = CreateMockAdditionalText(DUMMY_TEXT, sonarLintXmlPath);
            var projectOutputFile = CreateMockAdditionalText(DUMMY_TEXT, "ResourceTests\\ProjectOutFolderPath.txt");
            var analyzerOptions   = new AnalyzerOptions(ImmutableArray.Create(sonarLintFile.Object, projectOutputFile.Object));

            // Act
            var utilityAnalyzer = new TestUtilityAnalyzer();

            utilityAnalyzer.TestReadParameters(analyzerOptions, language);

            // Assert
            utilityAnalyzer.TestAnalyzeGeneratedCode.Should().Be(expectedAnalyzeGeneratedCodeValue);
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue();
        }
Ejemplo n.º 8
0
        public void UtilityAnalyzerBase_ReadParameters_OutputPath(string language, string expectedWorkDirectoryPath)
        {
            // we do not test what is read from the SonarLint file, but we need it
            var sonarLintFile = CreateMockAdditionalText(DUMMY_TEXT, "ResourceTests\\SonarLint.xml");
            // the output path is inside this file:
            var projectOutputFile = CreateMockAdditionalText(DUMMY_TEXT, "ResourceTests\\ProjectOutFolderPath.txt");
            var analyzerOptions   = new AnalyzerOptions(ImmutableArray.Create(sonarLintFile.Object, projectOutputFile.Object));

            // Act
            var utilityAnalyzer = new TestUtilityAnalyzer();

            utilityAnalyzer.TestReadParameters(analyzerOptions, language);

            // Assert
            utilityAnalyzer.TestWorkDirectoryBasePath.Should().Be(expectedWorkDirectoryPath);
            utilityAnalyzer.TestIsAnalyzerEnabled.Should().BeTrue();
        }