public void ProjectBindingOperation_Initialize_VariousRuleSetsReferenceAndDontReferenceSolutionRuleSet() { projectMock.SetVBProjectKind(); const string notReferencesConfigurationName = "config2"; // Arrange var testSubject = CreateTestSubject(); var references = CreateRuleSetProperty(projectMock, "config1", "references.ruleset"); var notReferences = CreateRuleSetProperty(projectMock, notReferencesConfigurationName, "notreferences.ruleset"); ruleSetReferenceChecker .Setup(x => x.IsReferenced(It.Is((RuleSetDeclaration r) => r.RuleSetPath == "references.ruleset"), cSharpVBBindingConfig.RuleSet.Path)) .Returns(true); ruleSetReferenceChecker .Setup(x => x.IsReferenced(It.Is((RuleSetDeclaration r) => r.RuleSetPath == "notreferences.ruleset"), cSharpVBBindingConfig.RuleSet.Path)) .Returns(false); // Act testSubject.Initialize(); // Assert testSubject.PropertyInformationMap.Keys.Should().NotContain(references); testSubject.PropertyInformationMap.Keys.Should().Contain(notReferences); var expectedRuleSetForNotReferences = Path.GetFileNameWithoutExtension(projectMock.FilePath) + "." + notReferencesConfigurationName; testSubject.PropertyInformationMap[notReferences].TargetRuleSetFileName.Should().Be(expectedRuleSetForNotReferences); }
public void BindingUtilities_IsProjectLevelBindingRequired() { // 1. C# -> binding is required var csProject = new ProjectMock("c:\\foo.proj"); csProject.SetCSProjectKind(); BindingRefactoringDumpingGround.IsProjectLevelBindingRequired(csProject).Should().BeTrue(); // 2. VB.NET -> binding is required var vbProject = new ProjectMock("c:\\foo.proj"); vbProject.SetVBProjectKind(); BindingRefactoringDumpingGround.IsProjectLevelBindingRequired(vbProject).Should().BeTrue(); // 3. Cpp -> binding is required var cppProject = new ProjectMock("c:\\foo.proj"); cppProject.ProjectKind = ProjectSystemHelper.CppProjectKind; BindingRefactoringDumpingGround.IsProjectLevelBindingRequired(cppProject).Should().BeFalse(); // 4. Other -> binding is not required var otherProject = new ProjectMock("c:\\foo.proj"); otherProject.ProjectKind = "{" + Guid.NewGuid().ToString() + "}"; BindingRefactoringDumpingGround.IsProjectLevelBindingRequired(otherProject).Should().BeFalse(); }
public void Get_VbNetProject_CSharpVBProjectBinderReturned() { var project = new ProjectMock("c:\\foo.proj"); project.SetVBProjectKind(); using (new AssertIgnoreScope()) { var configProjectBinder = testSubject.Get(project); configProjectBinder.Should().BeOfType <CSharpVBProjectBinder>(); } }
public void ProjectSystemFilter_IsAccepted_NoSupportedProject() { // Setup var testSubject = this.CreateTestSubject(); var project = new ProjectMock("unsupported.vbproj"); project.SetVBProjectKind(); // VB is not supported project.SetBuildProperty(Constants.SonarQubeTestProjectBuildPropertyKey, "False"); // Should not matter // Act var result = testSubject.IsAccepted(project); // Verify Assert.IsFalse(result, "Project of unsupported language type should not be accepted"); }