Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
georgii-borovinskikh-sonarsource committed Dec 18, 2024
1 parent 784f139 commit 4333c33
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/SLCore.UnitTests/Analysis/SLCoreAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

using NSubstitute.ExceptionExtensions;
using SonarLint.VisualStudio.CFamily.Analysis;
using SonarLint.VisualStudio.Core;
using SonarLint.VisualStudio.Core.Analysis;
using SonarLint.VisualStudio.Core.CFamily;
Expand Down Expand Up @@ -182,6 +183,23 @@ public void ExecuteAnalysis_ForCFamily_PassesCompilationDatabaseAsExtraPropertie
compilationDatabaseHandle.Received().Dispose();
}

[TestMethod]
public void ExecuteAnalysis_CFamilyReproducerEnabled_SetsExtraProperty()
{
const string filePath = @"C:\file\path\myclass.cpp";
SetUpCompilationDatabaseLocator(filePath, CreateCompilationDatabaseHandle("somepath"));
SetUpInitializedConfigScope();
var cFamilyAnalyzerOptions = Substitute.For<ICFamilyAnalyzerOptions>();
cFamilyAnalyzerOptions.CreateReproducer.Returns(true);

testSubject.ExecuteAnalysis(filePath, analysisId, [AnalysisLanguage.CFamily], cFamilyAnalyzerOptions, default);

analysisService.Received().AnalyzeFilesAndTrackAsync(Arg.Is<AnalyzeFilesAndTrackParams>(a =>
a.extraProperties != null
&& a.extraProperties["sonar.cfamily.reproducer"] == filePath),
Arg.Any<CancellationToken>());
}

[TestMethod]
public void ExecuteAnalysis_ForCFamily_AnalysisThrows_CompilationDatabaaseDisposed()
{
Expand Down

0 comments on commit 4333c33

Please sign in to comment.