From 645d6dd99ce10b300f68f3a6d7e24dd49b6b136f Mon Sep 17 00:00:00 2001 From: Cristian Ambrosini Date: Mon, 13 Mar 2023 11:46:22 +0100 Subject: [PATCH] UTs methods renaming --- .../Helpers/ParameterLoaderTest.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs index 92ab7ccbbd2..d9c047c1d40 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Helpers/ParameterLoaderTest.cs @@ -34,7 +34,7 @@ public class ParameterLoaderTest [TestMethod] [DataRow("path//aSonarLint.xml")] // different name [DataRow("path//SonarLint.xmla")] // different extension - public void SetParameterValues_WhenNoSonarLintIsGiven_DoesNotPopulateParameters(string filePath) + public void SetParameterValues_WithInvalidSonarLintPath_DoesNotPopulateParameters(string filePath) { // Arrange var compilation = CreateCompilationWithOption(filePath, SourceText.From(File.ReadAllText("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"))); @@ -50,7 +50,7 @@ public void SetParameterValues_WhenNoSonarLintIsGiven_DoesNotPopulateParameters( [TestMethod] [DataRow("a/SonarLint.xml")] // unix path [DataRow("a\\SonarLint.xml")] - public void SetParameterValues_WhenGivenValidSonarLintFilePath_PopulatesProperties(string filePath) + public void SetParameterValues_WithValidSonarLintPath_PopulatesProperties(string filePath) { // Arrange var compilation = CreateCompilationWithOption(filePath, SourceText.From(File.ReadAllText("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"))); @@ -64,7 +64,7 @@ public void SetParameterValues_WhenGivenValidSonarLintFilePath_PopulatesProperti } [TestMethod] - public void SetParameterValues_WhenGivenSonarLintFileHasIntParameterType_PopulatesProperties() + public void SetParameterValues_SonarLintFileWithIntParameterType_PopulatesProperties() { // Arrange var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"); @@ -78,11 +78,11 @@ public void SetParameterValues_WhenGivenSonarLintFileHasIntParameterType_Populat } [TestMethod] - public void SetParameterValues_WhenGivenSonarLintFileHasStringParameterType_OnlyOneParameter_PopulatesProperty() + public void SetParameterValues_SonarLintFileWithStringParameterType_PopulatesProperty() { // Arrange var parameterValue = "1"; - var filePath = GenerateSonarLintWithParametrizedRule("S2342", "flagsAttributeFormat", parameterValue); + var filePath = GenerateSonarLintXmlWithParametrizedRule("S2342", "flagsAttributeFormat", parameterValue); var compilation = CreateCompilationWithOption(filePath); var analyzer = new EnumNameShouldFollowRegex(); // Cannot use mock because we use reflection to find properties. @@ -94,11 +94,11 @@ public void SetParameterValues_WhenGivenSonarLintFileHasStringParameterType_Only } [TestMethod] - public void SetParameterValues_WhenGivenSonarLintFileHasBooleanParameterType_OnlyOneParameter_PopulatesProperty() + public void SetParameterValues_SonarLintFileWithBooleanParameterType_PopulatesProperty() { // Arrange var parameterValue = true; - var filePath = GenerateSonarLintWithParametrizedRule("S1451", "isRegularExpression", parameterValue.ToString()); + var filePath = GenerateSonarLintXmlWithParametrizedRule("S1451", "isRegularExpression", parameterValue.ToString()); var compilation = CreateCompilationWithOption(filePath); var analyzer = new CheckFileLicense(); // Cannot use mock because we use reflection to find properties. @@ -110,7 +110,7 @@ public void SetParameterValues_WhenGivenSonarLintFileHasBooleanParameterType_Onl } [TestMethod] - public void SetParameterValues_WhenGivenValidSonarLintFileAndDoesNotContainAnalyzerParameters_DoesNotPopulateProperties() + public void SetParameterValues_SonarLintFileWithoutRuleParameters_DoesNotPopulateProperties() { // Arrange var compilation = CreateCompilationWithOption("ResourceTests\\SonarLintXml\\All_properties_cs\\SonarLint.xml"); @@ -181,11 +181,11 @@ public void SetParameterValues_WithMalformedXml_DoesNotPopulateProperties(string } [TestMethod] - public void SetParameterValues_WithWrongPropertyType_StringInsteadOfInt_DoesNotPopulateProperties() + public void SetParameterValues_SonarLintFileWithStringInsteadOfIntParameterType_PopulatesProperty() { // Arrange var parameterValue = "fooBar"; - var filePath = GenerateSonarLintWithParametrizedRule("S1067", "max", parameterValue); + var filePath = GenerateSonarLintXmlWithParametrizedRule("S1067", "max", parameterValue); var compilation = CreateCompilationWithOption(filePath); var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties. @@ -197,11 +197,11 @@ public void SetParameterValues_WithWrongPropertyType_StringInsteadOfInt_DoesNotP } [TestMethod] - public void SetParameterValues_WithWrongPropertyType_StringInsteadOfBoolean_DoesNotPopulateProperties() + public void SetParameterValues_SonarLintFileWithStringInsteadOfBooleanParameterType_PopulatesProperty() { // Arrange var parameterValue = "fooBar"; - var filePath = GenerateSonarLintWithParametrizedRule("S1451", "isRegularExpression", parameterValue); + var filePath = GenerateSonarLintXmlWithParametrizedRule("S1451", "isRegularExpression", parameterValue); var compilation = CreateCompilationWithOption(filePath); var analyzer = new CheckFileLicense(); // Cannot use mock because we use reflection to find properties. @@ -221,7 +221,7 @@ private static SonarCompilationReportingContext CreateCompilationWithOption(stri var compilationContext = new CompilationAnalysisContext(compilation, options, _ => { }, _ => true, default); return new(AnalysisScaffolding.CreateSonarAnalysisContext(), compilationContext); } - private string GenerateSonarLintWithParametrizedRule(string ruleId, string key, string value) + private string GenerateSonarLintXmlWithParametrizedRule(string ruleId, string key, string value) { var ruleParameters = new List() {