コード例 #1
0
        public void EncodeAsMultiValueProperty_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.EncodeAsMultiValueProperty(paths);
            var actual66 = testSubject66.EncodeAsMultiValueProperty(paths);

            // Assert
            actual65.Should().Be(@"""C:\foo.cs"",\
""C:\foo,bar.cs"",\
""C:\foo""""bar.cs""");
            actual66.Should().Be(actual65);
        }
コード例 #2
0
        private void EncodeAsMultiValueProperty_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.EncodeAsMultiValueProperty(paths);

            // Assert
            actual.Should().Be(@"C:\foo.cs,\
C:\foobar.cs");
        }
コード例 #3
0
        private void EncodeAsMultiValueProperty_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.EncodeAsMultiValueProperty(paths);

            // Assert
            actual.Should().Be(@"C:\foo.cs");
            logger.Warnings.Should().HaveCount(1);
            logger.Warnings[0].Should().Be("The following paths contain invalid characters and will be excluded from this analysis: C:\\foo,bar.cs");
        }