public void PropertiesWriter_WorkdirPerModuleExplicitlySet() { // Tests that .sonar.working.directory is explicityl set per module // Arrange string projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten"); string productProject = CreateEmptyFile(projectBaseDir, "MyProduct.csproj"); string productFile = CreateEmptyFile(projectBaseDir, "File.cs"); List <string> productFiles = new List <string> { productFile }; string productFileListFilePath = Path.Combine(projectBaseDir, "productManagedFiles.txt"); string projectKey = "7B3B7244-5031-4D74-9BBD-3316E6B5E7D5"; ProjectInfo product = CreateProjectInfo("AnalysisSettingsTest.proj", projectKey, productProject, false, productFiles, productFileListFilePath, null, "language", "UTF-8"); List <ProjectInfo> projects = new List <ProjectInfo> { product }; AnalysisConfig config = new AnalysisConfig() { SonarOutputDir = @"C:\my_folder" }; // Act PropertiesWriter writer = new PropertiesWriter(config); writer.WriteSettingsForProject(product, new string[] { productFile }, null); writer.WriteSonarProjectInfo("dummy basedir", new List <string>()); string s = writer.Flush(); var props = new JavaProperties(); props.Load(GenerateStreamFromString(s)); string key = projectKey + "." + SonarProperties.WorkingDirectory; Assert.IsTrue(props.ContainsKey(key)); }
public void PropertiesWriter_WorkdirPerModuleExplicitlySet() { // Tests that .sonar.working.directory is explicitly set per module // Arrange var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten"); var productProject = CreateEmptyFile(projectBaseDir, "MyProduct.csproj"); var productFile = CreateEmptyFile(projectBaseDir, "File.cs"); var productFiles = new List <FileInfo> { productFile }; var productFileListFilePath = Path.Combine(projectBaseDir, "productManagedFiles.txt"); var projectKey = "7B3B7244-5031-4D74-9BBD-3316E6B5E7D5"; var product = new ProjectData(CreateProjectInfo("AnalysisSettingsTest.proj", projectKey, productProject, false, productFiles, productFileListFilePath, null, "language", "UTF-8")); product.ReferencedFiles.Add(productFile); var config = new AnalysisConfig() { SonarOutputDir = @"C:\my_folder" }; // Act var writer = new PropertiesWriter(config, new TestLogger()); writer.WriteSettingsForProject(product); writer.WriteSonarProjectInfo(new DirectoryInfo("dummy basedir")); var s = writer.Flush(); var props = new JavaProperties(); props.Load(GenerateStreamFromString(s)); var key = projectKey + "." + SonarProperties.WorkingDirectory; #pragma warning disable DictionaryShouldContainKey // Simplify Assertion props.ContainsKey(key).Should().BeTrue(); #pragma warning restore DictionaryShouldContainKey // Simplify Assertion }