diff --git a/src/SLCore.UnitTests/Analysis/SLCoreAnalyzerTests.cs b/src/SLCore.UnitTests/Analysis/SLCoreAnalyzerTests.cs index a5c263185..b2dc3e0f5 100644 --- a/src/SLCore.UnitTests/Analysis/SLCoreAnalyzerTests.cs +++ b/src/SLCore.UnitTests/Analysis/SLCoreAnalyzerTests.cs @@ -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; @@ -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(); + cFamilyAnalyzerOptions.CreateReproducer.Returns(true); + + testSubject.ExecuteAnalysis(filePath, analysisId, [AnalysisLanguage.CFamily], cFamilyAnalyzerOptions, default); + + analysisService.Received().AnalyzeFilesAndTrackAsync(Arg.Is(a => + a.extraProperties != null + && a.extraProperties["sonar.cfamily.reproducer"] == filePath), + Arg.Any()); + } + [TestMethod] public void ExecuteAnalysis_ForCFamily_AnalysisThrows_CompilationDatabaaseDisposed() {