Skip to content

Commit

Permalink
fix remaining failing UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Mar 13, 2023
1 parent 4a2cebb commit 6f3a31d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
Expand Up @@ -27,10 +27,10 @@ namespace SonarAnalyzer.AnalysisContext;

public class SonarAnalysisContextBase
{
protected static readonly ConditionalWeakTable<Compilation, ConcurrentDictionary<string, bool>> FileInclusionCache = new();
protected static readonly ConditionalWeakTable<Compilation, ImmutableHashSet<string>> UnchangedFilesCache = new();
protected static readonly SourceTextValueProvider<ProjectConfigReader> ProjectConfigProvider = new(x => new ProjectConfigReader(x));
protected static readonly SourceTextValueProvider<SonarLintXmlReader> SonarLintXmlProvider = new(x => new SonarLintXmlReader(x));
private protected static readonly ConditionalWeakTable<Compilation, ConcurrentDictionary<string, bool>> FileInclusionCache = new();
private protected static readonly ConditionalWeakTable<Compilation, ImmutableHashSet<string>> UnchangedFilesCache = new();
private protected static readonly SourceTextValueProvider<ProjectConfigReader> ProjectConfigProvider = new(x => new ProjectConfigReader(x));
private protected static readonly SourceTextValueProvider<SonarLintXmlReader> SonarLintXmlProvider = new(x => new SonarLintXmlReader(x));

protected SonarAnalysisContextBase() { }
}
Expand Down
Expand Up @@ -181,8 +181,8 @@ public void SonarLintFile_LoadsExpectedValues(string language)
var options = AnalysisScaffolding.CreateOptions($"ResourceTests\\SonarLintXml\\All_properties_{language}\\SonarLint.xml");
var sut = CreateSut(compilation, options).SonarLintFile();

sut.IgnoreHeaderComments(language).Should().BeTrue();
sut.AnalyzeGeneratedCode(language).Should().BeFalse();
sut.IgnoreHeaderComments(analyzerLanguage.ToString()).Should().BeTrue();
sut.AnalyzeGeneratedCode(analyzerLanguage.ToString()).Should().BeFalse();
AssertArrayContent(sut.Exclusions, nameof(sut.Exclusions));
AssertArrayContent(sut.Inclusions, nameof(sut.Inclusions));
AssertArrayContent(sut.GlobalExclusions, nameof(sut.GlobalExclusions));
Expand Down
Expand Up @@ -27,11 +27,11 @@ namespace SonarAnalyzer.UnitTest.Helpers;
public class SonarLintXmlReaderTest
{
[DataTestMethod]
[DataRow(LanguageNames.CSharp)]
[DataRow(LanguageNames.VisualBasic)]
public void SonarLintXmlReader_WhenAllValuesAreSet_ExpectedValues(string language)
[DataRow(LanguageNames.CSharp, "cs")]
[DataRow(LanguageNames.VisualBasic, "vbnet")]
public void SonarLintXmlReader_WhenAllValuesAreSet_ExpectedValues(string language, string xmlLanguageName)
{
var sut = CreateSonarLintXmlReader($"ResourceTests\\SonarLintXml\\All_Properties_{language}\\SonarLint.xml");
var sut = CreateSonarLintXmlReader($"ResourceTests\\SonarLintXml\\All_Properties_{xmlLanguageName}\\SonarLint.xml");
sut.IgnoreHeaderComments(language).Should().BeTrue();
sut.AnalyzeGeneratedCode(language).Should().BeFalse();
AssertArrayContent(sut.Exclusions, nameof(sut.Exclusions));
Expand All @@ -56,14 +56,12 @@ static void AssertArrayContent(string[] array, string folder)
}
}

[DataTestMethod]
[DataRow(LanguageNames.CSharp)]
[DataRow(LanguageNames.VisualBasic)]
public void SonarLintXmlReader_PartiallyMissingProperties_ExpectedAndDefaultValues(string language)
[TestMethod]
public void SonarLintXmlReader_PartiallyMissingProperties_ExpectedAndDefaultValues()
{
var sut = CreateSonarLintXmlReader("ResourceTests\\SonarLintXml\\Partially_missing_properties\\SonarLint.xml");
sut.IgnoreHeaderComments(language).Should().BeFalse();
sut.AnalyzeGeneratedCode(language).Should().BeTrue();
sut.IgnoreHeaderComments().Should().BeFalse();
sut.AnalyzeGeneratedCode().Should().BeTrue();
AssertArrayContent(sut.Exclusions, nameof(sut.Exclusions));
AssertArrayContent(sut.Inclusions, nameof(sut.Inclusions));
sut.GlobalExclusions.Should().NotBeNull().And.HaveCount(0);
Expand Down

0 comments on commit 6f3a31d

Please sign in to comment.