Esempio n. 1
0
        public void Get_StandaloneMode()
        {
            // Arrange
            var builder = new TestEnvironmentBuilder(SonarLintMode.Standalone)
            {
                ConnectedModeSettings = new UserSettings
                {
                    Rules = new Dictionary <string, RuleConfig>
                    {
                        { "cpp:rule1", new RuleConfig {
                              Level = RuleLevel.Off
                          } },
                        { "cpp:rule2", new RuleConfig {
                              Level = RuleLevel.On
                          } },
                        { "cpp:rule3", new RuleConfig {
                              Level = RuleLevel.On
                          } },
                        { "XXX:rule3", new RuleConfig {
                              Level = RuleLevel.On
                          } }
                    }
                },

                StandaloneModeSettings = new UserSettings
                {
                    Rules = new Dictionary <string, RuleConfig>
                    {
                        { "cpp:rule1", new RuleConfig {
                              Level = RuleLevel.On
                          } },
                        { "cpp:rule2", new RuleConfig {
                              Level = RuleLevel.Off
                          } },
                        { "cpp:rule4", new RuleConfig {
                              Level = RuleLevel.On
                          } },
                        { "XXX:rule3", new RuleConfig {
                              Level = RuleLevel.On
                          } }
                    }
                },

                SonarWayConfig = new DummyCFamilyRulesConfig("cpp")
                                 .AddRule("rule1", IssueSeverity.Blocker, isActive: false)
                                 .AddRule("rule2", IssueSeverity.Critical, isActive: false)
                                 .AddRule("rule3", IssueSeverity.Major, isActive: true)
                                 .AddRule("rule4", IssueSeverity.Minor, isActive: false)
            };

            var testSubject = builder.CreateTestSubject();

            // Act
            var result = testSubject.GetRulesConfiguration("cpp");

            // Assert
            result.ActivePartialRuleKeys.Should().BeEquivalentTo("rule1", "rule3", "rule4");
            result.AllPartialRuleKeys.Should().BeEquivalentTo("rule1", "rule2", "rule3", "rule4");

            builder.AssertConnectedSettingsNotAccessed();
        }