public void GetUnboundProjects_ValidSolution_ReturnsProjectsThatRequireBinding(int numberOfUnboundProjects)
        {
            var testConfig = new TestConfigurationBuilder();
            var project1   = testConfig.AddFilteredProject(ProjectSystemHelper.CSharpProjectKind);
            var project2   = testConfig.AddFilteredProject(ProjectSystemHelper.VbCoreProjectKind);
            var project3   = testConfig.AddFilteredProject(ProjectSystemHelper.CppProjectKind);

            var allProjects = new List <Project> {
                project1, project2, project3
            };
            var unboundProjects = allProjects.Take(numberOfUnboundProjects).ToList();
            var boundProjects   = allProjects.Except(unboundProjects).ToList();

            foreach (var boundProject in boundProjects)
            {
                testConfig.SetupProjectBindingRequired(boundProject, true);
            }
            foreach (var boundProject in unboundProjects)
            {
                testConfig.SetupProjectBindingRequired(boundProject, false);
            }

            var testSubject = testConfig.CreateTestSubject();

            var result = testSubject.GetUnboundProjects();

            result.Should().AllBeEquivalentTo(unboundProjects);
        }
Exemplo n.º 2
0
        public void GetUnboundProjects_ValidSolution_CFamily_RequiresBothCppAndCConfig(SonarLintMode mode,
                                                                                       bool cppConfigExists, bool cConfigExists)
        {
            // Cpp projects should have both C++ and C solution-level rules config files
            var shouldBeBound = cppConfigExists && cConfigExists;

            // Arrange
            var testConfig = new TestConfigurationBuilder(mode, "sqKey1");
            var projectCpp = testConfig.AddFilteredProject(ProjectSystemHelper.CppProjectKind);

            testConfig.SetSolutionLevelFilePathForLanguage(Language.Cpp, "c:\\slnConfig.cpp", cppConfigExists);
            testConfig.SetSolutionLevelFilePathForLanguage(Language.C, "c:\\slnConfig.c", cConfigExists);

            var testSubject = testConfig.CreateTestSubject();

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

            // Assert
            if (shouldBeBound)
            {
                result.Should().BeEmpty();
            }
            else
            {
                result.Should().BeEquivalentTo(projectCpp);
            }
        }
        public void GetUnboundProjects_SolutionBound_EmptyFilteredProjects()
        {
            // Arrange - no projects created
            var testConfig = new TestConfigurationBuilder();

            var testSubject = testConfig.CreateTestSubject();

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

            // Assert
            AssertEmptyResult(result);
        }
Exemplo n.º 4
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");
        }
Exemplo n.º 5
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");
        }