public void WriteAnalyzerOutputPaths_WritesEncodedPaths(string language, string expectedPropertyKey)
        {
            var config           = new AnalysisConfig();
            var propertiesWriter = new PropertiesWriter(config, new TestLogger());
            var someGuid         = new Guid("5762C17D-1DDF-4C77-86AC-E2B4940926A9");

            var projectInfo = new ProjectInfo()
            {
                ProjectGuid = someGuid, ProjectLanguage = language
            };
            var projectData = new ProjectData(projectInfo);

            projectData.AnalyzerOutPaths.Add(new FileInfo(@"c:\dir1\first"));
            projectData.AnalyzerOutPaths.Add(new FileInfo(@"c:\dir1\second"));

            propertiesWriter.WriteAnalyzerOutputPaths(projectData);

            propertiesWriter.Flush().Should().Be(
                $@"5762C17D-1DDF-4C77-86AC-E2B4940926A9.{expectedPropertyKey}=\
c:\\dir1\\first,\
c:\\dir1\\second
sonar.modules=

");
        }
Ejemplo n.º 2
0
 public void PropertiesWriterEscape()
 {
     Assert.AreEqual("foo", PropertiesWriter.Escape("foo"));
     Assert.AreEqual(@"C:\\File.cs", PropertiesWriter.Escape(@"C:\File.cs"));
     Assert.AreEqual(@"\u4F60\u597D", PropertiesWriter.Escape("你好"));
     Assert.AreEqual(@"\u000A", PropertiesWriter.Escape("\n"));
 }
        public void PropertiesWriter_InvalidOperations()
        {
            AnalysisConfig validConfig = new AnalysisConfig()
            {
                SonarProjectKey     = "key",
                SonarProjectName    = "name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = this.TestContext.DeploymentDirectory
            };

            // 1. Must supply an analysis config on construction
            AssertException.Expects <ArgumentNullException>(() => new PropertiesWriter(null));


            // 2. Can't call WriteSettingsForProject after Flush
            PropertiesWriter writer = new PropertiesWriter(validConfig);

            writer.Flush();
            AssertException.Expects <InvalidOperationException>(() => writer.Flush());

            // 3. Can't call Flush twice
            writer = new PropertiesWriter(validConfig);
            writer.Flush();
            using (new AssertIgnoreScope())
            {
                AssertException.Expects <InvalidOperationException>(() => writer.WriteSettingsForProject(new ProjectInfo(), new string[] { "file" }, "fxCopReport", "code coverage report"));
            }
        }
 public void PropertiesWriterEscape()
 {
     PropertiesWriter.Escape("foo").Should().Be("foo");
     PropertiesWriter.Escape(@"C:\File.cs").Should().Be(@"C:\\File.cs");
     PropertiesWriter.Escape("你好").Should().Be(@"\u4F60\u597D");
     PropertiesWriter.Escape("\n").Should().Be(@"\u000A");
 }
        public void EncodeAsSonarQubeMultiValueProperty_WhenSQGreaterThanOrEqualTo65_EscapeAndJoinPaths()
        {
            // Arrange
            var config65 = new AnalysisConfig
            {
                SonarOutputDir   = @"C:\my_folder",
                SonarQubeVersion = "6.5"
            };
            var config66 = new AnalysisConfig
            {
                SonarOutputDir   = @"C:\my_folder",
                SonarQubeVersion = "6.6"
            };

            var testSubject65 = new PropertiesWriter(config65, new TestLogger());
            var testSubject66 = new PropertiesWriter(config66, new TestLogger());

            var paths = new[] { "C:\\foo.cs", "C:\\foo,bar.cs", "C:\\foo\"bar.cs" };

            // Act
            var actual65 = testSubject65.EncodeAsSonarQubeMultiValueProperty(paths);
            var actual66 = testSubject66.EncodeAsSonarQubeMultiValueProperty(paths);

            // Assert
            actual65.Should().Be(@"""C:\foo.cs"",\
""C:\foo,bar.cs"",\
""C:\foo""""bar.cs""");
            actual66.Should().Be(actual65);
        }
        private void VerifyProjectBaseDir(string expectedValue, string teamBuildValue, string userValue, string[] projectPaths)
        {
            AnalysisConfig   config = new AnalysisConfig();
            PropertiesWriter writer = new PropertiesWriter(config);

            config.SonarOutputDir = TestSonarqubeOutputDir;

            config.SourcesDirectory = teamBuildValue;
            config.SetConfigValue(SonarProperties.ProjectBaseDir, userValue);

            using (new AssertIgnoreScope())
            {
                foreach (string projectPath in projectPaths)
                {
                    var projectInfo = new ProjectInfo {
                        FullPath = projectPath, ProjectLanguage = ProjectLanguages.CSharp
                    };
                    writer.WriteSettingsForProject(projectInfo, Enumerable.Empty <string>(), "", "");
                }

                var actual   = writer.Flush();
                var expected = "\r\nsonar.projectBaseDir=" + PropertiesWriter.Escape(expectedValue);

                Assert.IsTrue(actual.Contains(expected));
            }
        }
        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");
        }
Ejemplo n.º 8
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            PropertiesWriter writer = new PropertiesWriter(Server.TW);

            writer.Write();
            //SwitchServer.SwitchServerLoc(installPath, "lolt.properties");
            //serverLocation.Text = "台服";
        }
        public void PropertiesWriter_FxCopRerportForUnrecognisedLanguage()
        {
            var    productBaseDir          = TestUtils.CreateTestSpecificFolder(TestContext);
            string productProject          = CreateEmptyFile(productBaseDir, "MyProduct.proj");
            string productFile             = CreateEmptyFile(productBaseDir, "File.txt");
            string productFxCopFilePath    = CreateEmptyFile(productBaseDir, "productFxCopReport.txt");
            string productFileListFilePath = Path.Combine(productBaseDir, "productFileList.txt");

            List <string> productFiles = new List <string>();

            productFiles.Add(productFile);
            ProjectInfo product = CreateProjectInfo("myproduct", "9507E2E6-7342-4A04-9CB9-B0C47C937019", productProject, false, productFiles, productFileListFilePath, productFxCopFilePath, null, "my.language");

            AnalysisConfig config = new AnalysisConfig()
            {
                SonarProjectKey     = "my_project_key",
                SonarProjectName    = "my_project_name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = @"C:\my_folder",
                SourcesDirectory    = @"D:\sources"
            };

            string actual = null;

            using (new AssertIgnoreScope()) // expecting the property writer to complain about having an FxCop report for an unknown language
            {
                PropertiesWriter writer = new PropertiesWriter(config);
                writer.WriteSettingsForProject(product, new string[] { productFile, }, productFxCopFilePath, null);
                actual = writer.Flush();
            }

            string expected = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                            @"9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.projectKey=my_project_key:9507E2E6-7342-4A04-9CB9-B0C47C937019
9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.projectName=myproduct
9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.projectBaseDir={0}
9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.sources=\
{0}\\File.txt

sonar.projectKey=my_project_key
sonar.projectName=my_project_name
sonar.projectVersion=1.0
sonar.working.directory=C:\\my_folder\\.sonar
sonar.projectBaseDir={1}

# FIXME: Encoding is hardcoded
sonar.sourceEncoding=UTF-8

sonar.modules=9507E2E6-7342-4A04-9CB9-B0C47C937019

",
                                            PropertiesWriter.Escape(productBaseDir),
                                            PropertiesWriter.Escape(config.SourcesDirectory));

            SaveToResultFile(productBaseDir, "Expected.txt", expected.ToString());
            SaveToResultFile(productBaseDir, "Actual.txt", actual);

            Assert.AreEqual(expected, actual);
        }
        public void PropertiesWriter_AnalysisSettingsWritten()
        {
            // Tests that analysis settings in the ProjectInfo are written to the file
            // 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");

            ProjectInfo product = CreateProjectInfo("AnalysisSettingsTest.proj", "7B3B7244-5031-4D74-9BBD-3316E6B5E7D5", productProject, false, productFiles, productFileListFilePath, null, "language", "UTF-8");

            List <ProjectInfo> projects = new List <ProjectInfo>
            {
                product
            };

            AnalysisConfig config = new AnalysisConfig()
            {
                SonarOutputDir = @"C:\my_folder"
            };

            // These are the settings we are going to check. The other analysis values are not checked.
            product.AnalysisSettings = 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
            };

            // Act
            PropertiesWriter writer = new PropertiesWriter(config);

            writer.WriteSettingsForProject(product, new string[] { productFile }, null);
            string fullActualPath = SaveToResultFile(projectBaseDir, "Actual.txt", writer.Flush());

            // Assert
            SQPropertiesFileReader propertyReader = new SQPropertiesFileReader(fullActualPath);

            propertyReader.AssertSettingExists("7B3B7244-5031-4D74-9BBD-3316E6B5E7D5.my.setting1", "setting1");
            propertyReader.AssertSettingExists("7B3B7244-5031-4D74-9BBD-3316E6B5E7D5.my.setting2", "setting 2 with spaces");
            propertyReader.AssertSettingExists("7B3B7244-5031-4D74-9BBD-3316E6B5E7D5.my.setting.3", @"c:\dir1\dir2\foo.txt");
        }
Ejemplo n.º 11
0
        public void Save()
        {
            if (IsSaving)
            {
                return;
            }

            PropertiesWriter.Serialize(serverConfig);
            IsSaving = true;
            worldPersistence.Save(world, serverConfig.SaveName);
            IsSaving = false;
        }
        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");
        }
Ejemplo n.º 13
0
        private static void RegisterCoreDependencies(ContainerBuilder containerBuilder)
        {
            containerBuilder.Register(c => PropertiesWriter.Deserialize <ServerConfig>()).SingleInstance();
            containerBuilder.RegisterType <Server>().SingleInstance();
            containerBuilder.RegisterType <PlayerManager>().SingleInstance();
            containerBuilder.RegisterType <DefaultServerPacketProcessor>().InstancePerLifetimeScope();
            containerBuilder.RegisterType <PacketHandler>().InstancePerLifetimeScope();
            containerBuilder.RegisterType <EscapePodManager>().InstancePerLifetimeScope();
            containerBuilder.RegisterType <EntitySimulation>().SingleInstance();
            containerBuilder.RegisterType <ConsoleCommandProcessor>().SingleInstance();

            containerBuilder.RegisterType <LiteNetLibServer>()
            .As <Communication.NetworkingLayer.NitroxServer>()
            .SingleInstance();
        }
Ejemplo n.º 14
0
        public void Flush_WhenCalledTwice_ThrowsInvalidOperationException()
        {
            // Arrange
            var validConfig = new AnalysisConfig()
            {
                SonarProjectKey     = "key",
                SonarProjectName    = "name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = TestContext.DeploymentDirectory
            };

            var writer = new PropertiesWriter(validConfig, new TestLogger());

            writer.Flush();

            // Act & Assert
            AssertException.Expects <InvalidOperationException>(() => writer.Flush());
        }
        private void EncodeAsSonarQubeMultiValueProperty_WhenGivenSQVersionAndNoInvalidPath_JoinPaths(string sonarqubeVersion)
        {
            // Arrange
            var config = new AnalysisConfig
            {
                SonarOutputDir   = @"C:\my_folder",
                SonarQubeVersion = sonarqubeVersion
            };

            var testSubject = new PropertiesWriter(config, new TestLogger());
            var paths       = new[] { "C:\\foo.cs", "C:\\foobar.cs" };

            // Act
            var actual = testSubject.EncodeAsSonarQubeMultiValueProperty(paths);

            // Assert
            actual.Should().Be(@"C:\foo.cs,\
C:\foobar.cs");
        }
        public void WriteAnalyzerOutputPaths_WritesEncodedAnalyzerOutPaths()
        {
            var config           = new AnalysisConfig();
            var propertiesWriter = new PropertiesWriter(config, new TestLogger());
            var someGuid         = new Guid("5762C17D-1DDF-4C77-86AC-E2B4940926A9");

            var projectInfo = new ProjectInfo()
            {
                ProjectGuid = someGuid
            };
            var projectData = new ProjectData(projectInfo);

            projectData.AnalyzerOutPaths.Add(new FileInfo(@"c:\dir1\dir2"));

            propertiesWriter.WriteAnalyzerOutputPaths(projectData);

            propertiesWriter.Flush().Should()
            .Be("5762C17D-1DDF-4C77-86AC-E2B4940926A9.=\\\r\nc:\\\\dir1\\\\dir2\r\nsonar.modules=\r\n\r\n");
        }
Ejemplo n.º 17
0
        private void VerifyProjectBaseDir(string expectedValue, string teamBuildValue, string userValue, string[] projectPaths)
        {
            AnalysisConfig   config = new AnalysisConfig();
            PropertiesWriter writer = new PropertiesWriter(config);

            config.SonarOutputDir = TestSonarqubeOutputDir;

            config.SourcesDirectory = teamBuildValue;
            config.SetConfigValue(SonarProperties.ProjectBaseDir, userValue);

            TestLogger logger = new TestLogger();

            // Act
            string result = PropertiesFileGenerator.ComputeRootProjectBaseDir(config, projectPaths.Select(p => new ProjectInfo {
                FullPath = p, ProjectLanguage = ProjectLanguages.CSharp
            }));

            result.Should().Be(expectedValue);
        }
        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 Flush_WhenCalledTwice_ThrowsInvalidOperationException()
        {
            // Arrange
            var validConfig = new AnalysisConfig()
            {
                SonarProjectKey     = "key",
                SonarProjectName    = "name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = TestUtils.CreateTestSpecificFolder(TestContext)
            };

            var writer = new PropertiesWriter(validConfig, new TestLogger());

            writer.Flush();

            // Act & Assert
            Action act = () => writer.Flush();

            act.Should().ThrowExactly <InvalidOperationException>();
        }
        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
        }
        private void EncodeAsSonarQubeMultiValueProperty_WhenGivenSQVersionAndInvalidPath_ExcludeInvalidPathAndJoinOthers(string sonarqubeVersion)
        {
            // Arrange
            var config = new AnalysisConfig
            {
                SonarOutputDir   = @"C:\my_folder",
                SonarQubeVersion = sonarqubeVersion
            };

            var logger      = new TestLogger();
            var testSubject = new PropertiesWriter(config, logger);
            var paths       = new[] { "C:\\foo.cs", "C:\\foo,bar.cs" };

            // Act
            var actual = testSubject.EncodeAsSonarQubeMultiValueProperty(paths);

            // Assert
            actual.Should().Be(@"C:\foo.cs");
            logger.Warnings.Should().HaveCount(1);
            logger.Warnings[0].Should().Be("The following paths contain invalid characters for this version of SonarQube and will be excluded from this analysis: C:\\foo,bar.cs");
        }
        public void WriteAnalyzerOutputPaths_ForUnexpectedLanguage_DoNotWritesOutPaths()
        {
            var config           = new AnalysisConfig();
            var propertiesWriter = new PropertiesWriter(config, new TestLogger());
            var someGuid         = new Guid("5762C17D-1DDF-4C77-86AC-E2B4940926A9");

            var projectInfo = new ProjectInfo()
            {
                ProjectGuid = someGuid, ProjectLanguage = "unexpected"
            };
            var projectData = new ProjectData(projectInfo);

            projectData.AnalyzerOutPaths.Add(new FileInfo(@"c:\dir1\dir2"));

            propertiesWriter.WriteAnalyzerOutputPaths(projectData);

            propertiesWriter.Flush().Should().Be(
                @"sonar.modules=

");
        }
Ejemplo n.º 23
0
        protected override void Execute(CallArgs args)
        {
            if (!configOpenLock.Wait(0))
            {
                Log.Warn("Waiting on previous config command to close the configuration file.");
                return;
            }

            ServerConfig currentActiveConfig = NitroxServiceLocator.LocateService <ServerConfig>();
            string       configFile          = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? "", currentActiveConfig.FileName);

            if (!File.Exists(configFile))
            {
                Log.Error($"Could not find config file at: {configFile}");
                return;
            }

            Task.Run(async() =>
            {
                try
                {
                    await StartWithDefaultProgram(configFile);
                }
                finally
                {
                    configOpenLock.Release();
                }
                PropertiesWriter.Deserialize <ServerConfig>();    // Notifies user if deserialization failed.
                Log.Info("If you made changes, restart the server for them to take effect.");
            })
            .ContinueWith(t =>
            {
#if DEBUG
                if (t.Exception != null)
                {
                    throw t.Exception;
                }
#endif
            });
        }
Ejemplo n.º 24
0
        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");
        }
Ejemplo n.º 25
0
        private string ComputeProjectBaseDir(string teamBuildValue, string userValue, string[] projectPaths)
        {
            var config = new AnalysisConfig();
            var writer = new PropertiesWriter(config);

            config.SonarOutputDir = TestSonarqubeOutputDir;

            config.SourcesDirectory = teamBuildValue;

            if (config.LocalSettings == null)
            {
                config.LocalSettings = new AnalysisProperties();
            }
            config.LocalSettings.Add(new Property {
                Id = SonarProperties.ProjectBaseDir, Value = userValue
            });

            var logger = new TestLogger();

            // Act
            return(new PropertiesFileGenerator(config, logger).ComputeRootProjectBaseDir(projectPaths));
        }
        public void WriteSettingsForProject_WhenFlushed_ThrowsInvalidOperationException()
        {
            // Arrange
            var validConfig = new AnalysisConfig()
            {
                SonarProjectKey     = "key",
                SonarProjectName    = "name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = TestUtils.CreateTestSpecificFolder(TestContext)
            };

            var writer = new PropertiesWriter(validConfig, new TestLogger());

            writer.Flush();

            // Act & Assert
            using (new AssertIgnoreScope())
            {
                Action act = () => writer.WriteSettingsForProject(new ProjectData(new ProjectInfo()));
                act.Should().ThrowExactly <InvalidOperationException>();
            }
        }
Ejemplo n.º 27
0
        public void WriteSettingsForProject_WhenFlushed_ThrowsInvalidOperationException()
        {
            // Arrange
            var validConfig = new AnalysisConfig()
            {
                SonarProjectKey     = "key",
                SonarProjectName    = "name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = TestContext.DeploymentDirectory
            };

            var writer = new PropertiesWriter(validConfig, new TestLogger());

            writer.Flush();

            // Act & Assert
            using (new AssertIgnoreScope())
            {
                AssertException.Expects <InvalidOperationException>(
                    () => writer.WriteSettingsForProject(new ProjectData(new ProjectInfo())));
            }
        }
Ejemplo n.º 28
0
        private void AssertHasProjectBaseDir(string expectedProjectDir, string fallback, params string[] projectPaths)
        {
            var config = new AnalysisConfig();

            config.SonarOutputDir = fallback;
            var writer = new PropertiesWriter(config);

            using (new AssertIgnoreScope())
            {
                foreach (string projectPath in projectPaths)
                {
                    var projectInfo = new ProjectInfo {
                        FullPath = projectPath, ProjectLanguage = ProjectLanguages.VisualBasic
                    };
                    writer.WriteSettingsForProject(projectInfo, Enumerable.Empty <string>(), "", "");
                }
                var actual   = writer.Flush();
                var expected = "\r\nsonar.projectBaseDir=" + PropertiesWriter.Escape(expectedProjectDir);

                Console.WriteLine(actual);

                Assert.IsTrue(actual.Contains(expected));
            }
        }
Ejemplo n.º 29
0
        private static void AssertFileIsReferenced(string fullFilePath, string content, int times = 1)
        {
            var formattedPath = PropertiesWriter.Escape(fullFilePath);

            var index = content.IndexOf(formattedPath);

            if (times == 0)
            {
                index.Should().Be(-1, $"File should not be referenced: {formattedPath}");
            }
            else
            {
                index.Should().NotBe(-1, $"File should be referenced: {formattedPath}");

                for (var i = 0; i < times - 1; i++)
                {
                    index = content.IndexOf(formattedPath, index + 1);
                    index.Should().NotBe(-1, $"File should be referenced exactly {times} times: {formattedPath}");
                }

                index = content.IndexOf(formattedPath, index + 1);
                index.Should().Be(-1, $"File should be referenced exactly {times} times: {formattedPath}");
            }
        }
        public void PropertiesWriterToString()
        {
            var productBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_ProductBaseDir");
            string productProject = CreateEmptyFile(productBaseDir, "MyProduct.csproj");
            string productFile = CreateEmptyFile(productBaseDir, "File.cs");
            string productChineseFile = CreateEmptyFile(productBaseDir, "你好.cs");

            string productFxCopFilePath = CreateEmptyFile(productBaseDir, "productFxCopReport.txt");
            string productCoverageFilePath = CreateEmptyFile(productBaseDir, "productCoverageReport.txt");
            string productFileListFilePath = Path.Combine(productBaseDir, "productManagedFiles.txt");

            string otherDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_OtherDir");
            string missingFileOutsideProjectDir = Path.Combine(otherDir, "missing.cs");

            List<string> productFiles = new List<string>();
            productFiles.Add(productFile);
            productFiles.Add(productChineseFile);
            productFiles.Add(missingFileOutsideProjectDir);
            ProjectInfo productCS = CreateProjectInfo("你好", "DB2E5521-3172-47B9-BA50-864F12E6DFFF", productProject, false, productFiles, productFileListFilePath, productFxCopFilePath, productCoverageFilePath, ProjectLanguages.CSharp);
            ProjectInfo productVB = CreateProjectInfo("vbProject", "B51622CF-82F4-48C9-9F38-FB981FAFAF3A", productProject, false, productFiles, productFileListFilePath, productFxCopFilePath, productCoverageFilePath, ProjectLanguages.VisualBasic);

            string testBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_TestBaseDir");
            string testProject = CreateEmptyFile(testBaseDir, "MyTest.csproj");
            string testFile = CreateEmptyFile(testBaseDir, "File.cs");
            string testFileListFilePath = Path.Combine(testBaseDir, "testManagedFiles.txt");

            List<string> testFiles = new List<string>();
            testFiles.Add(testFile);
            ProjectInfo test = CreateProjectInfo("my_test_project", "DA0FCD82-9C5C-4666-9370-C7388281D49B", testProject, true, testFiles, testFileListFilePath, null, null, ProjectLanguages.VisualBasic);

            AnalysisConfig config = new AnalysisConfig()
            {
                SonarProjectKey = "my_project_key",
                SonarProjectName = "my_project_name",
                SonarProjectVersion = "1.0",
                SonarOutputDir = @"C:\my_folder"
            };

            string actual = null;
            using (new AssertIgnoreScope()) // expecting the property writer to complain about the missing file
            {
                PropertiesWriter writer = new PropertiesWriter(config);
                writer.WriteSettingsForProject(productCS, new string[] { productFile, productChineseFile, missingFileOutsideProjectDir }, productFxCopFilePath, productCoverageFilePath);
                writer.WriteSettingsForProject(productVB, new string[] { productFile }, productFxCopFilePath, null);
                writer.WriteSettingsForProject(test, new string[] { testFile }, null, null);

                actual = writer.Flush();
            }

            string expected = string.Format(System.Globalization.CultureInfo.InvariantCulture,
@"DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.projectKey=my_project_key:DB2E5521-3172-47B9-BA50-864F12E6DFFF
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.projectName=\u4F60\u597D
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.projectBaseDir={0}
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.cs.fxcop.reportPath={1}
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.cs.vscoveragexml.reportsPaths={2}
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.sources=\
{0}\\File.cs,\
{0}\\\u4F60\u597D.cs,\
{4}

B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.projectKey=my_project_key:B51622CF-82F4-48C9-9F38-FB981FAFAF3A
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.projectName=vbProject
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.projectBaseDir={0}
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.vbnet.fxcop.reportPath={1}
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.sources=\
{0}\\File.cs

DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.projectKey=my_project_key:DA0FCD82-9C5C-4666-9370-C7388281D49B
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.projectName=my_test_project
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.projectBaseDir={3}
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.sources=
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.tests=\
{3}\\File.cs

sonar.projectKey=my_project_key
sonar.projectName=my_project_name
sonar.projectVersion=1.0
sonar.projectBaseDir={5}
sonar.working.directory=C:\\my_folder\\.sonar

# FIXME: Encoding is hardcoded
sonar.sourceEncoding=UTF-8

sonar.modules=DB2E5521-3172-47B9-BA50-864F12E6DFFF,B51622CF-82F4-48C9-9F38-FB981FAFAF3A,DA0FCD82-9C5C-4666-9370-C7388281D49B

",
 PropertiesWriter.Escape(productBaseDir),
 PropertiesWriter.Escape(productFxCopFilePath),
 PropertiesWriter.Escape(productCoverageFilePath),
 PropertiesWriter.Escape(testBaseDir),
 PropertiesWriter.Escape(missingFileOutsideProjectDir),
 PropertiesWriter.Escape(TestUtils.GetTestSpecificFolderName(TestContext)));

            SaveToResultFile(productBaseDir, "Expected.txt", expected.ToString());
            SaveToResultFile(productBaseDir, "Actual.txt", actual);

            Assert.AreEqual(expected, actual);
        }
        private void AssertHasProjectBaseDir(string expectedProjectDir, string fallback, params string[] projectPaths)
        {
            var config = new AnalysisConfig();
            config.SonarOutputDir = fallback;
            var writer = new PropertiesWriter(config);

            using (new AssertIgnoreScope())
            {
                foreach (string projectPath in projectPaths)
                {
                    var projectInfo = new ProjectInfo { FullPath = projectPath, ProjectLanguage = ProjectLanguages.VisualBasic };
                    writer.WriteSettingsForProject(projectInfo, Enumerable.Empty<string>(), "", "");
                }
                var actual = writer.Flush();
                var expected = "\r\nsonar.projectBaseDir=" + PropertiesWriter.Escape(expectedProjectDir);

                Console.WriteLine(actual);

                Assert.IsTrue(actual.Contains(expected));
            }
        }
        private void VerifyProjectBaseDir(string expectedValue, string teamBuildValue, string userValue, string[] projectPaths)
        {
            AnalysisConfig config = new AnalysisConfig();
            PropertiesWriter writer = new PropertiesWriter(config);
            config.SonarOutputDir = TestSonarqubeOutputDir;

            config.SourcesDirectory = teamBuildValue;
            config.SetConfigValue(SonarProperties.ProjectBaseDir, userValue);

            using (new AssertIgnoreScope())
            {
                foreach (string projectPath in projectPaths)
                {
                    var projectInfo = new ProjectInfo { FullPath = projectPath, ProjectLanguage = ProjectLanguages.CSharp };
                    writer.WriteSettingsForProject(projectInfo, Enumerable.Empty<string>(), "", "");
                }

                var actual = writer.Flush();
                var expected = "\r\nsonar.projectBaseDir=" + PropertiesWriter.Escape(expectedValue);

                Assert.IsTrue(actual.Contains(expected));
            }
        }
Ejemplo n.º 33
0
 public void Save(string comment)
 {
     PropertiesWriter writer = new PropertiesWriter(properties, comment);
     Write(new StreamAction(writer.Store));
 }
        public void PropertiesWriter_InvalidOperations()
        {
            AnalysisConfig validConfig = new AnalysisConfig()
            {
                SonarProjectKey = "key",
                SonarProjectName = "name",
                SonarProjectVersion = "1.0",
                SonarOutputDir = this.TestContext.DeploymentDirectory
            };

            // 1. Must supply an analysis config on construction
            AssertException.Expects<ArgumentNullException>(() => new PropertiesWriter(null));


            // 2. Can't call WriteSettingsForProject after Flush
            PropertiesWriter writer = new PropertiesWriter(validConfig);
            writer.Flush();
            AssertException.Expects<InvalidOperationException>(() => writer.Flush());

            // 3. Can't call Flush twice
            writer = new PropertiesWriter(validConfig);
            writer.Flush();
            using (new AssertIgnoreScope())
            {
                AssertException.Expects<InvalidOperationException>(() => writer.WriteSettingsForProject(new ProjectInfo(), new string[] { "file" }, "fxCopReport", "code coverage report"));
            }
        }
        public void PropertiesWriter_AnalysisSettingsWritten()
        {
            // Tests that analysis settings in the ProjectInfo are written to the file
            // 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>();
            productFiles.Add(productFile);
            string productFileListFilePath = Path.Combine(projectBaseDir, "productManagedFiles.txt");

            ProjectInfo product = CreateProjectInfo("AnalysisSettingsTest.proj", "7B3B7244-5031-4D74-9BBD-3316E6B5E7D5", productProject, false, productFiles, productFileListFilePath, null, null, "language");

            List<ProjectInfo> projects = new List<ProjectInfo>();
            projects.Add(product);

            AnalysisConfig config = new AnalysisConfig()
            {
                SonarOutputDir = @"C:\my_folder"
            };

            // These are the settings we are going to check. The other analysis values are not checked.
            product.AnalysisSettings = new AnalysisProperties();
            product.AnalysisSettings.Add(new Property() { Id = "my.setting1", Value = "setting1" });
            product.AnalysisSettings.Add(new Property() { Id = "my.setting2", Value = "setting 2 with spaces" });
            product.AnalysisSettings.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.WriteSettingsForProject(product, new string[] { productFile }, null, null);          
            string fullActualPath = SaveToResultFile(projectBaseDir, "Actual.txt", writer.Flush());

            // Assert
            SQPropertiesFileReader propertyReader = new SQPropertiesFileReader(fullActualPath);

            propertyReader.AssertSettingExists("7B3B7244-5031-4D74-9BBD-3316E6B5E7D5.my.setting1", "setting1");
            propertyReader.AssertSettingExists("7B3B7244-5031-4D74-9BBD-3316E6B5E7D5.my.setting2", "setting 2 with spaces");
            propertyReader.AssertSettingExists("7B3B7244-5031-4D74-9BBD-3316E6B5E7D5.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");
        }
        public void PropertiesWriterToString()
        {
            var productBaseDir     = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_ProductBaseDir");
            var productProject     = CreateEmptyFile(productBaseDir, "MyProduct.csproj");
            var productFile        = CreateEmptyFile(productBaseDir, "File.cs");
            var productChineseFile = CreateEmptyFile(productBaseDir, "你好.cs");

            var productCoverageFilePath = CreateEmptyFile(productBaseDir, "productCoverageReport.txt").FullName;

            CreateEmptyFile(productBaseDir, "productTrx.trx");
            var productFileListFilePath = Path.Combine(productBaseDir, "productManagedFiles.txt");

            var otherDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_OtherDir");
            var missingFileOutsideProjectDir = new FileInfo(Path.Combine(otherDir, "missing.cs"));

            var productFiles = new List <FileInfo>
            {
                productFile,
                productChineseFile,
                missingFileOutsideProjectDir
            };
            var productCS = new ProjectData(CreateProjectInfo("你好", "DB2E5521-3172-47B9-BA50-864F12E6DFFF", productProject, false, productFiles, productFileListFilePath, productCoverageFilePath, ProjectLanguages.CSharp, "UTF-8"));

            productCS.SonarQubeModuleFiles.Add(productFile);
            productCS.SonarQubeModuleFiles.Add(productChineseFile);
            productCS.SonarQubeModuleFiles.Add(missingFileOutsideProjectDir);

            var productVB = new ProjectData(CreateProjectInfo("vbProject", "B51622CF-82F4-48C9-9F38-FB981FAFAF3A", productProject, false, productFiles, productFileListFilePath, productCoverageFilePath, ProjectLanguages.VisualBasic, "UTF-8"));

            productVB.SonarQubeModuleFiles.Add(productFile);

            var testBaseDir          = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_TestBaseDir");
            var testProject          = CreateEmptyFile(testBaseDir, "MyTest.csproj");
            var testFile             = CreateEmptyFile(testBaseDir, "File.cs");
            var testFileListFilePath = Path.Combine(testBaseDir, "testManagedFiles.txt");

            var testFiles = new List <FileInfo>
            {
                testFile
            };
            var test = new ProjectData(CreateProjectInfo("my_test_project", "DA0FCD82-9C5C-4666-9370-C7388281D49B", testProject, true, testFiles, testFileListFilePath, null, ProjectLanguages.VisualBasic, "UTF-8"));

            test.SonarQubeModuleFiles.Add(testFile);

            var config = new AnalysisConfig()
            {
                SonarProjectKey     = "my_project_key",
                SonarProjectName    = "my_project_name",
                SonarProjectVersion = "1.0",
                SonarOutputDir      = @"C:\my_folder",
                SourcesDirectory    = @"d:\source_files\"
            };

            string actual = null;

            using (new AssertIgnoreScope()) // expecting the property writer to complain about the missing file
            {
                var writer = new PropertiesWriter(config, new TestLogger());
                writer.WriteSettingsForProject(productCS);
                writer.WriteSettingsForProject(productVB);
                writer.WriteSettingsForProject(test);

                actual = writer.Flush();
            }

            var expected = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                         @"DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.projectKey=my_project_key:DB2E5521-3172-47B9-BA50-864F12E6DFFF
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.projectName=\u4F60\u597D
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.projectBaseDir={0}
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.sourceEncoding=utf-8
DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.sources=\
{0}\\File.cs,\
{0}\\\u4F60\u597D.cs,\
{2}

DB2E5521-3172-47B9-BA50-864F12E6DFFF.sonar.working.directory=C:\\my_folder\\.sonar\\mod0
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.projectKey=my_project_key:B51622CF-82F4-48C9-9F38-FB981FAFAF3A
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.projectName=vbProject
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.projectBaseDir={0}
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.sourceEncoding=utf-8
B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.sources=\
{0}\\File.cs

B51622CF-82F4-48C9-9F38-FB981FAFAF3A.sonar.working.directory=C:\\my_folder\\.sonar\\mod1
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.projectKey=my_project_key:DA0FCD82-9C5C-4666-9370-C7388281D49B
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.projectName=my_test_project
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.projectBaseDir={1}
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.sourceEncoding=utf-8
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.sources=
DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.tests=\
{1}\\File.cs

DA0FCD82-9C5C-4666-9370-C7388281D49B.sonar.working.directory=C:\\my_folder\\.sonar\\mod2
sonar.modules=DB2E5521-3172-47B9-BA50-864F12E6DFFF,B51622CF-82F4-48C9-9F38-FB981FAFAF3A,DA0FCD82-9C5C-4666-9370-C7388281D49B

",
                                         PropertiesWriter.Escape(productBaseDir),
                                         PropertiesWriter.Escape(testBaseDir),
                                         PropertiesWriter.Escape(missingFileOutsideProjectDir));

            SaveToResultFile(productBaseDir, "Expected.txt", expected.ToString());
            SaveToResultFile(productBaseDir, "Actual.txt", actual);

            actual.Should().Be(expected);
        }
        public void PropertiesWriter_FxCopRerportForUnrecognisedLanguage()
        {
            var productBaseDir = TestUtils.CreateTestSpecificFolder(TestContext);
            string productProject = CreateEmptyFile(productBaseDir, "MyProduct.proj");
            string productFile = CreateEmptyFile(productBaseDir, "File.txt");
            string productFxCopFilePath = CreateEmptyFile(productBaseDir, "productFxCopReport.txt");
            string productFileListFilePath = Path.Combine(productBaseDir, "productFileList.txt");

            List<string> productFiles = new List<string>();
            productFiles.Add(productFile);
            ProjectInfo product = CreateProjectInfo("myproduct", "9507E2E6-7342-4A04-9CB9-B0C47C937019", productProject, false, productFiles, productFileListFilePath, productFxCopFilePath, null, "my.language");

            AnalysisConfig config = new AnalysisConfig()
            {
                SonarProjectKey = "my_project_key",
                SonarProjectName = "my_project_name",
                SonarProjectVersion = "1.0",
                SonarOutputDir = @"C:\my_folder"
            };

            string actual = null;
            using (new AssertIgnoreScope()) // expecting the property writer to complain about having an FxCop report for an unknown language
            {
                PropertiesWriter writer = new PropertiesWriter(config);
                writer.WriteSettingsForProject(product, new string[] { productFile, }, productFxCopFilePath, null);
                actual = writer.Flush();
            }

            string expected = string.Format(System.Globalization.CultureInfo.InvariantCulture,
@"9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.projectKey=my_project_key:9507E2E6-7342-4A04-9CB9-B0C47C937019
9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.projectName=myproduct
9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.projectBaseDir={0}
9507E2E6-7342-4A04-9CB9-B0C47C937019.sonar.sources=\
{0}\\File.txt

sonar.projectKey=my_project_key
sonar.projectName=my_project_name
sonar.projectVersion=1.0
sonar.projectBaseDir={1}
sonar.working.directory=C:\\my_folder\\.sonar

# FIXME: Encoding is hardcoded
sonar.sourceEncoding=UTF-8

sonar.modules=9507E2E6-7342-4A04-9CB9-B0C47C937019

",
 PropertiesWriter.Escape(productBaseDir),
 PropertiesWriter.Escape(TestUtils.GetTestSpecificFolderName(TestContext)));

            SaveToResultFile(productBaseDir, "Expected.txt", expected.ToString());
            SaveToResultFile(productBaseDir, "Actual.txt", actual);

            Assert.AreEqual(expected, actual);
        }