Example #1
0
        public void GetUnboundProjects_ValidSolution_SolutionRuleConfigIsMissing(SonarLintMode mode)
        {
            // If the solution ruleset is missing then all projects will be returned as unbound
            // Arrange - no projects created
            var testConfig = new TestConfigurationBuilder(mode, "sqKey1");
            var project1   = testConfig.AddFilteredProject(ProjectSystemHelper.CSharpProjectKind);
            var project2   = testConfig.AddFilteredProject(ProjectSystemHelper.VbCoreProjectKind);
            var project3   = testConfig.AddFilteredProject(ProjectSystemHelper.CppProjectKind);

            testConfig.SetSolutionLevelFilePathForLanguage(Language.CSharp, "c:\\slnConfig.csharp", false);
            testConfig.SetSolutionLevelFilePathForLanguage(Language.VBNET, "c:\\slnConfig.vb", false);
            testConfig.SetSolutionLevelFilePathForLanguage(Language.Cpp, "c:\\slnConfig.cpp", false);

            var testSubject = testConfig.CreateTestSubject();

            // Act
            var result = testSubject.GetUnboundProjects();

            // Assert
            result.Should().BeEquivalentTo(project1, project2, project3);
            testConfig.AssertExistenceOfFileWasChecked("c:\\slnConfig.csharp");
            testConfig.AssertExistenceOfFileWasChecked("c:\\slnConfig.vb");
            testConfig.AssertExistenceOfFileWasChecked("c:\\slnConfig.cpp");
        }
Example #2
0
        public void GetUnboundProjects_Connected_ValidSolution_ProjectLevelBindingIsNotRequired_ProjectsAreNotChecked()
        {
            // Arrange
            var testConfig = new TestConfigurationBuilder(SonarLintMode.Connected, "xxx_key");

            testConfig.SetSolutionLevelFilePathForLanguage(Language.Cpp, "c:\\existingConfig.cpp", true);
            testConfig.SetSolutionLevelFilePathForLanguage(Language.C, "c:\\existingConfig.c", true);
            testConfig.AddFilteredProject(ProjectSystemHelper.CppProjectKind);

            var testSubject = testConfig.CreateTestSubject();

            // Act
            var projects = testSubject.GetUnboundProjects();

            // Assert
            projects.Should().BeEmpty();
            testConfig.AssertExistenceOfFileWasChecked("c:\\existingConfig.cpp");
            testConfig.AssertNoAttemptToLoadRulesetFile("c:\\existingConfig.cpp");
        }