public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ArgChecks() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider, new Mock <ILogger>().Object, new MockFileSystem()); // Act + Assert Exceptions.Expect <ArgumentNullException>(() => testSubject.GetProjectRuleSetsDeclarations(null).ToArray()); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ArgChecks() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); // Act + Verify Exceptions.Expect<ArgumentNullException>(() => testSubject.GetProjectRuleSetsDeclarations(null).ToArray()); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ArgChecks() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); // Act + Verify Exceptions.Expect <ArgumentNullException>(() => testSubject.GetProjectRuleSetsDeclarations(null).ToArray()); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_ArgChecks() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); // Act Verify Exceptions.Expect <ArgumentNullException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath(null, Language.CSharp)); Exceptions.Expect <ArgumentNullException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath(null, Language.VBNET)); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_OnClosedSolution() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); this.projectSystemHelper.CurrentActiveSolution = new SolutionMock(null, "" /*When the solution is closed the file is empty*/); // Act + Assert Exceptions.Expect <InvalidOperationException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey", Language.CSharp)); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_OnClosedSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, "" /*When the solution is closed the file is empty*/); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // Act + Verify Exceptions.Expect <InvalidOperationException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey", Language.CSharp)); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationPropertyWithDefaultValue() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock prop1 = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(1, info.Length, "Unexpected number of results"); VerifyRuleSetInformation(info[0], prop1); this.outputPane.AssertOutputStrings(0); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationWithNoRuleSetProperty() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); CreateProperty(this.projectMock, "config1", "Custom1.ruleset", Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(0, info.Length, "Unexpected number of results"); this.outputPane.AssertOutputStrings(1); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationPropertyWithDefaultValue() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock prop1 = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(1, info.Length, "Unexpected number of results"); VerifyRuleSetInformation(info[0], prop1); this.outputPane.AssertOutputStrings(0); }
public void SolutionRuleSetsInformationProvider_GetSolutionSonarQubeRulesFolder_OnClosedSolution() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); this.projectSystemHelper.CurrentActiveSolution = new SolutionMock(null, "" /*When the solution is closed the file is empty*/); // // Act string path = testSubject.GetSolutionSonarQubeRulesFolder(); // Assert path.Should().BeNull(); }
public void SolutionRuleSetsInformationProvider_GetSolutionSonarQubeRulesFolder_OnOpenSolution() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); this.projectSystemHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); // // Act string path = testSubject.GetSolutionSonarQubeRulesFolder(); // Assert path.Should().Be(@"z:\folder\solution\SonarQube"); }
public void SolutionRuleSetsInformationProvider_GetSolutionSonarQubeRulesFolder_OnClosedSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, "" /*When the solution is closed the file is empty*/); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // // Act string path = testSubject.GetSolutionSonarQubeRulesFolder(); // Verify Assert.IsNull(path); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationPropertyWithEmptyRuleSets() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock prop1 = CreateProperty(this.projectMock, "config1", null); PropertyMock prop2 = CreateProperty(this.projectMock, "config2", string.Empty); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Assert info.Should().HaveCount(2, "Unexpected number of results"); VerifyRuleSetInformation(info[0], prop1); VerifyRuleSetInformation(info[1], prop2); this.outputPane.AssertOutputStrings(0); }
public void TestInitialize() { this.dte = new DTEMock(); this.serviceProvider = new ConfigurableServiceProvider(); this.solutionMock = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln")); this.projectMock = this.solutionMock.AddOrGetProject(Path.Combine(SolutionRoot, @"Project\project.proj")); this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); var outputWindow = new ConfigurableVsOutputWindow(); this.outputPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystemHelper); this.testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider, new SonarLintOutputLogger(serviceProvider)); }
public void SolutionRuleSetsInformationProvider_GetSolutionSonarQubeRulesFolder_OnOpenSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // // Act string path = testSubject.GetSolutionSonarQubeRulesFolder(); // Verify Assert.AreEqual(@"z:\folder\solution\SonarQube", path); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationPropertyWithSameNonDefaultValues() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock prop1 = CreateProperty(this.projectMock, "config1", "Custom1.ruleset"); PropertyMock prop2 = CreateProperty(this.projectMock, "config2", @"x:\Folder\Custom2.ruleset"); PropertyMock prop3 = CreateProperty(this.projectMock, "config3", @"..\Custom3.ruleset"); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(3, info.Length, "Unexpected number of results"); VerifyRuleSetInformation(info[0], prop1); VerifyRuleSetInformation(info[1], prop2); VerifyRuleSetInformation(info[2], prop3); this.outputPane.AssertOutputStrings(0); }
public void SolutionRuleSetsInformationProvider_TryGetProjectRuleSetFilePath() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var fileSystem = new ConfigurableFileSystem(); this.serviceProvider.RegisterService(typeof(IFileSystem), fileSystem); ProjectMock project = new ProjectMock(@"c:\Solution\Project\Project1.myProj"); RuleSetDeclaration declaration; string ruleSetPath; // Case 1: Declaration has an full path which exists on disk declaration = CreateDeclaration(project, @"c:\RuleSet.ruleset"); fileSystem.RegisterFile(declaration.RuleSetPath); // Act Assert.IsTrue(testSubject.TryGetProjectRuleSetFilePath(project, declaration, out ruleSetPath)); // Verify Assert.AreEqual(@"c:\RuleSet.ruleset", ruleSetPath); // Case 2: Declaration is relative to project and on disk fileSystem.ClearFiles(); declaration = CreateDeclaration(project, @"..\RuleSet.ruleset"); fileSystem.RegisterFile(@"c:\Solution\RuleSet.ruleset"); // Act Assert.IsTrue(testSubject.TryGetProjectRuleSetFilePath(project, declaration, out ruleSetPath)); // Verify Assert.AreEqual(@"c:\Solution\RuleSet.ruleset", ruleSetPath); // Case 3: File doesn't exist fileSystem.ClearFiles(); declaration = CreateDeclaration(project, "MyFile.ruleset"); // Act Assert.IsFalse(testSubject.TryGetProjectRuleSetFilePath(project, declaration, out ruleSetPath)); // Verify Assert.IsNull(ruleSetPath); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_RuleSetsWithDirectories() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock ruleSet1 = CreateProperty(this.projectMock, "config1", "Custom1.ruleset"); CreateProperty(this.projectMock, "config1", @"x:\YYY\zzz", Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); PropertyMock ruleSet2 = CreateProperty(this.projectMock, "config2", "Custom1.ruleset"); CreateProperty(this.projectMock, "config2", @"x:\YYY\zzz;q:\;", Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(2, info.Length, "Unexpected number of results"); VerifyRuleSetInformation(info[0], ruleSet1); VerifyRuleSetInformation(info[1], ruleSet2); this.outputPane.AssertOutputStrings(0); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_OnOpenSolution() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); this.projectSystemHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); // Case 1: VB + invalid path characters // Act string ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey" + Path.GetInvalidPathChars().First(), Language.VBNET); // Assert ruleSetPath.Should().Be(@"z:\folder\solution\SonarQube\MyKey_VB.ruleset"); // Case 2: C# + valid path characters // Act ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey", Language.CSharp); // Assert ruleSetPath.Should().Be(@"z:\folder\solution\SonarQube\MyKeyCSharp.ruleset"); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_RuleSetsWithDirectories() { // Arrange var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock ruleSet1 = CreateProperty(this.projectMock, "config1", "Custom1.ruleset"); SetBuildProperty(this.projectSystemHelper, this.projectMock, Constants.CodeAnalysisRuleSetDirectoriesPropertyKey, @"x:\YYY\zzz", "config1"); PropertyMock ruleSet2 = CreateProperty(this.projectMock, "config2", "Custom1.ruleset"); SetBuildProperty(this.projectSystemHelper, this.projectMock, Constants.CodeAnalysisRuleSetDirectoriesPropertyKey, @"x:\YYY\zzz;q:\;", "config2"); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Assert info.Should().HaveCount(2, "Unexpected number of results"); VerifyRuleSetInformation(info[0], ruleSet1); VerifyRuleSetInformation(info[1], ruleSet2); this.outputPane.AssertOutputStrings(0); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_OnOpenSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // Case 1: VB + invalid path characters // Act string ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey" + Path.GetInvalidPathChars().First(), Language.VBNET); // Verify Assert.AreEqual(@"z:\folder\solution\SonarQube\MyKey_VB.ruleset", ruleSetPath); // Case 2: C# + valid path characters // Act ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey", Language.CSharp); // Verify Assert.AreEqual(@"z:\folder\solution\SonarQube\MyKeyCSharp.ruleset", ruleSetPath); }
public void SolutionRuleSetsInformationProvider_TryGetProjectRuleSetFilePath() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var fileSystem = new ConfigurableFileSystem(); this.serviceProvider.RegisterService(typeof(IFileSystem), fileSystem); ProjectMock project = new ProjectMock(@"c:\Solution\Project\Project1.myProj"); RuleSetDeclaration declaration; string ruleSetPath; // Case 1: Declaration has an full path which exists on disk declaration = CreateDeclaration(project, @"c:\RuleSet.ruleset"); fileSystem.RegisterFile(declaration.RuleSetPath); // Act Assert.IsTrue(testSubject.TryGetProjectRuleSetFilePath(project, declaration, out ruleSetPath)); // Verify Assert.AreEqual(@"c:\RuleSet.ruleset", ruleSetPath); // Case 2: Declaration is relative to project and on disk fileSystem.ClearFiles(); declaration = CreateDeclaration(project, @"..\RuleSet.ruleset"); fileSystem.RegisterFile(@"c:\Solution\RuleSet.ruleset"); // Act Assert.IsTrue(testSubject.TryGetProjectRuleSetFilePath(project, declaration, out ruleSetPath)); // Verify Assert.AreEqual(@"c:\Solution\RuleSet.ruleset", ruleSetPath); // Case 3: File doesn't exist fileSystem.ClearFiles(); declaration = CreateDeclaration(project, "MyFile.ruleset"); // Act Assert.IsFalse(testSubject.TryGetProjectRuleSetFilePath(project, declaration, out ruleSetPath)); // Verify Assert.IsNull(ruleSetPath); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationWithNoRuleSetProperty() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); CreateProperty(this.projectMock, "config1", "Custom1.ruleset", Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(0, info.Length, "Unexpected number of results"); this.outputPane.AssertOutputStrings(1); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_RuleSetsWithDirectories() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock ruleSet1 = CreateProperty(this.projectMock, "config1", "Custom1.ruleset"); CreateProperty(this.projectMock, "config1", @"x:\YYY\zzz", Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); PropertyMock ruleSet2 = CreateProperty(this.projectMock, "config2", "Custom1.ruleset"); CreateProperty(this.projectMock, "config2", @"x:\YYY\zzz;q:\;", Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(2, info.Length, "Unexpected number of results"); VerifyRuleSetInformation(info[0], ruleSet1); VerifyRuleSetInformation(info[1], ruleSet2); this.outputPane.AssertOutputStrings(0); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_ArgChecks() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); // Act Verify Exceptions.Expect<ArgumentNullException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath(null, Language.CSharp)); Exceptions.Expect<ArgumentNullException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath(null, Language.VBNET)); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_OnOpenSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // Case 1: VB + invalid path characters // Act string ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey" + Path.GetInvalidPathChars().First(), Language.VBNET); // Verify Assert.AreEqual(@"z:\folder\solution\SonarQube\MyKey_VB.ruleset", ruleSetPath); // Case 2: C# + valid path characters // Act ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey", Language.CSharp); // Verify Assert.AreEqual(@"z:\folder\solution\SonarQube\MyKeyCSharp.ruleset", ruleSetPath); }
public void SolutionRuleSetsInformationProvider_CalculateSolutionSonarQubeRuleSetFilePath_OnClosedSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, "" /*When the solution is closed the file is empty*/); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // Act + Verify Exceptions.Expect<InvalidOperationException>(() => testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MyKey", Language.CSharp)); }
public void SolutionRuleSetsInformationProvider_GetSolutionSonarQubeRulesFolder_OnOpenSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // // Act string path = testSubject.GetSolutionSonarQubeRulesFolder(); // Verify Assert.AreEqual(@"z:\folder\solution\SonarQube", path); }
public void SolutionRuleSetsInformationProvider_GetSolutionSonarQubeRulesFolder_OnClosedSolution() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); var projectHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); projectHelper.CurrentActiveSolution = new SolutionMock(null, "" /*When the solution is closed the file is empty*/); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectHelper); // // Act string path = testSubject.GetSolutionSonarQubeRulesFolder(); // Verify Assert.IsNull(path); }
public void SolutionRuleSetsInformationProvider_GetProjectRuleSetsDeclarations_ConfigurationPropertyWithSameNonDefaultValues() { // Setup var testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider); PropertyMock prop1 = CreateProperty(this.projectMock, "config1", "Custom1.ruleset"); PropertyMock prop2 = CreateProperty(this.projectMock, "config2", @"x:\Folder\Custom2.ruleset"); PropertyMock prop3 = CreateProperty(this.projectMock, "config3", @"..\Custom3.ruleset"); // Act RuleSetDeclaration[] info = testSubject.GetProjectRuleSetsDeclarations(this.projectMock).ToArray(); // Verify Assert.AreEqual(3, info.Length, "Unexpected number of results"); VerifyRuleSetInformation(info[0], prop1); VerifyRuleSetInformation(info[1], prop2); VerifyRuleSetInformation(info[2], prop3); this.outputPane.AssertOutputStrings(0); }