public void WriteGlobalSettings_ThrowsOnNullArgument() { var propertiesWriter = new PropertiesWriter(new AnalysisConfig(), new TestLogger()); Action action = () => propertiesWriter.WriteGlobalSettings(null); action.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("properties"); }
public void PropertiesWriter_GlobalSettingsWritten() { // Tests that global settings in the ProjectInfo are written to the file // Arrange var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_GlobalSettingsWritten"); var config = new AnalysisConfig() { SonarOutputDir = @"C:\my_folder" }; var globalSettings = new AnalysisProperties { new Property() { Id = "my.setting1", Value = "setting1" }, new Property() { Id = "my.setting2", Value = "setting 2 with spaces" }, new Property() { Id = "my.setting.3", Value = @"c:\dir1\dir2\foo.txt" }, // path that will be escaped // Specific test for sonar.branch property new Property() { Id = "sonar.branch", Value = "aBranch" } // path that will be escaped }; // Act var writer = new PropertiesWriter(config, new TestLogger()); writer.WriteGlobalSettings(globalSettings); var fullActualPath = SaveToResultFile(projectBaseDir, "Actual.txt", writer.Flush()); // Assert var propertyReader = new SQPropertiesFileReader(fullActualPath); propertyReader.AssertSettingExists("my.setting1", "setting1"); propertyReader.AssertSettingExists("my.setting2", "setting 2 with spaces"); propertyReader.AssertSettingExists("my.setting.3", @"c:\dir1\dir2\foo.txt"); propertyReader.AssertSettingExists("sonar.branch", "aBranch"); }
public void PropertiesWriter_GlobalSettingsWritten() { // Tests that global settings in the ProjectInfo are written to the file // Arrange string projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_GlobalSettingsWritten"); AnalysisConfig config = new AnalysisConfig() { SonarOutputDir = @"C:\my_folder" }; AnalysisProperties globalSettings = new AnalysisProperties(); globalSettings.Add(new Property() { Id = "my.setting1", Value = "setting1" }); globalSettings.Add(new Property() { Id = "my.setting2", Value = "setting 2 with spaces" }); globalSettings.Add(new Property() { Id = "my.setting.3", Value = @"c:\dir1\dir2\foo.txt" }); // path that will be escaped // Act PropertiesWriter writer = new PropertiesWriter(config); writer.WriteGlobalSettings(globalSettings); string fullActualPath = SaveToResultFile(projectBaseDir, "Actual.txt", writer.Flush()); // Assert SQPropertiesFileReader propertyReader = new SQPropertiesFileReader(fullActualPath); propertyReader.AssertSettingExists("my.setting1", "setting1"); propertyReader.AssertSettingExists("my.setting2", "setting 2 with spaces"); propertyReader.AssertSettingExists("my.setting.3", @"c:\\dir1\\dir2\\foo.txt"); }
public void PropertiesWriter_GlobalSettingsWritten() { // Tests that global settings in the ProjectInfo are written to the file // Arrange string projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_GlobalSettingsWritten"); AnalysisConfig config = new AnalysisConfig() { SonarOutputDir = @"C:\my_folder" }; AnalysisProperties globalSettings = new AnalysisProperties(); globalSettings.Add(new Property() { Id = "my.setting1", Value = "setting1" }); globalSettings.Add(new Property() { Id = "my.setting2", Value = "setting 2 with spaces" }); globalSettings.Add(new Property() { Id = "my.setting.3", Value = @"c:\dir1\dir2\foo.txt" }); // path that will be escaped // Act PropertiesWriter writer = new PropertiesWriter(config); writer.WriteGlobalSettings(globalSettings); string fullActualPath = SaveToResultFile(projectBaseDir, "Actual.txt", writer.Flush()); // Assert SQPropertiesFileReader propertyReader = new SQPropertiesFileReader(fullActualPath); propertyReader.AssertSettingExists("my.setting1", "setting1"); propertyReader.AssertSettingExists("my.setting2", "setting 2 with spaces"); propertyReader.AssertSettingExists("my.setting.3", @"c:\\dir1\\dir2\\foo.txt"); }