private static bool IsTestProjectPatternProperty(SonarQubeProperty property)
        {
            const string TestProjectRegexKey = "sonar.cs.msbuild.testProjectPattern";

            return(StringComparer.Ordinal.Equals(property.Key, TestProjectRegexKey));
        }
        public async Task GetConfig_HasActiveInactiveAndUnsupportedRules_ReturnsValidBindingConfig()
        {
            // Arrange
            const string expectedProjectName = "my project";
            const string expectedServerUrl   = "http://myhost:123/";

            var properties = new SonarQubeProperty[]
            {
                new SonarQubeProperty("propertyAAA", "111"), new SonarQubeProperty("propertyBBB", "222")
            };

            var activeRules = new SonarQubeRule[]
            {
                CreateRule("activeRuleKey", "repoKey1", true),
                ActiveTaintAnalysisRule,
                ActiveRuleWithUnsupportedSeverity
            };

            var inactiveRules = new SonarQubeRule[]
            {
                CreateRule("inactiveRuleKey", "repoKey2", false),
                InactiveTaintAnalysisRule,
                InactiveRuleWithUnsupportedSeverity
            };

            var builder = new TestEnvironmentBuilder(validQualityProfile, Language.CSharp, expectedProjectName, expectedServerUrl)
            {
                ActiveRulesResponse           = activeRules,
                InactiveRulesResponse         = inactiveRules,
                PropertiesResponse            = properties,
                NuGetBindingOperationResponse = true,
                RuleSetGeneratorResponse      = validRuleSet
            };

            var testSubject = builder.CreateTestSubject();

            // Act
            var result = await testSubject.GetConfigurationAsync(validQualityProfile, Language.CSharp, builder.BindingConfiguration, CancellationToken.None)
                         .ConfigureAwait(false);

            // Assert
            result.Should().NotBeNull();
            result.Should().BeOfType <CSharpVBBindingConfig>();
            var dotNetResult = (CSharpVBBindingConfig)result;

            dotNetResult.RuleSet.Should().NotBeNull();
            dotNetResult.RuleSet.Content.ToolsVersion.Should().Be(validRuleSet.ToolsVersion);

            var expectedName = string.Format(Strings.SonarQubeRuleSetNameFormat, expectedProjectName, validQualityProfile.Name);

            dotNetResult.RuleSet.Content.Name.Should().Be(expectedName);

            var expectedDescription = $"{OriginalValidRuleSetDescription} {string.Format(Strings.SonarQubeQualityProfilePageUrlFormat, expectedServerUrl, validQualityProfile.Key)}";

            dotNetResult.RuleSet.Content.Description.Should().Be(expectedDescription);

            // Check properties passed to the ruleset generator
            builder.CapturedPropertiesPassedToRuleSetGenerator.Should().NotBeNull();
            var capturedProperties = builder.CapturedPropertiesPassedToRuleSetGenerator.ToList();

            capturedProperties.Count.Should().Be(2);
            capturedProperties[0].Key.Should().Be("propertyAAA");
            capturedProperties[0].Value.Should().Be("111");
            capturedProperties[1].Key.Should().Be("propertyBBB");
            capturedProperties[1].Value.Should().Be("222");

            // Check both active and inactive rules were passed to the ruleset generator.
            // The unsupported rules should have been removed.
            builder.CapturedRulesPassedToRuleSetGenerator.Should().NotBeNull();
            var capturedRules = builder.CapturedRulesPassedToRuleSetGenerator.ToList();

            capturedRules.Count.Should().Be(2);
            capturedRules[0].Key.Should().Be("activeRuleKey");
            capturedRules[0].RepositoryKey.Should().Be("repoKey1");
            capturedRules[1].Key.Should().Be("inactiveRuleKey");
            capturedRules[1].RepositoryKey.Should().Be("repoKey2");

            builder.AssertNuGetBindingOpWasCalled();
            builder.Logger.AssertOutputStrings(0); // not expecting anything in the case of success
        }