public void IsSupported()
        {
            var testSubject = new CLangAnalyzer(telemetryManagerMock.Object, new ConfigurableSonarLintSettings(),
                                                rulesConfigProviderMock.Object, serviceProviderWithValidProjectItem.Object, analysisNotifierMock.Object, testLogger, Mock.Of <ICFamilyIssueToAnalysisIssueConverter>());

            testSubject.IsAnalysisSupported(new[] { AnalysisLanguage.CFamily }).Should().BeTrue();
            testSubject.IsAnalysisSupported(new[] { AnalysisLanguage.Javascript }).Should().BeFalse();
            testSubject.IsAnalysisSupported(new[] { AnalysisLanguage.Javascript, AnalysisLanguage.CFamily }).Should().BeTrue();
        }
Beispiel #2
0
        public void IsSupported()
        {
            // Arrange
            var telemetryManagerMock    = new Mock <ITelemetryManager>();
            var testLogger              = new TestLogger();
            var rulesConfigProviderMock = new Mock <ICFamilyRulesConfigProvider>();

            var analyzer = new CLangAnalyzer(telemetryManagerMock.Object, new ConfigurableSonarLintSettings(),
                                             rulesConfigProviderMock.Object, testLogger);

            // Act and Assert
            analyzer.IsAnalysisSupported(new[] { AnalysisLanguage.CFamily }).Should().BeTrue();
            analyzer.IsAnalysisSupported(new[] { AnalysisLanguage.Javascript }).Should().BeFalse();
            analyzer.IsAnalysisSupported(new[] { AnalysisLanguage.Javascript, AnalysisLanguage.CFamily }).Should().BeTrue();
        }
Beispiel #3
0
        public void TestIsIssueForActiveRule()
        {
            var rulesConfig = new DummyCFamilyRulesConfig("any")
                              .AddRule("rule1", isActive: true)
                              .AddRule("rule2", isActive: false);

            // 1. Match - active
            var message = new Message("rule1", "filename", 0, 0, 0, 0, "msg", false, null);

            CLangAnalyzer.IsIssueForActiveRule(message, rulesConfig).Should().BeTrue();

            // 2. Match - not active
            message = new Message("rule2", "filename", 0, 0, 0, 0, "msg", false, null);
            CLangAnalyzer.IsIssueForActiveRule(message, rulesConfig).Should().BeFalse();

            // 3. No match - case-sensitivity
            message = new Message("RULE1", "filename", 0, 0, 0, 0, "msg", false, null);
            CLangAnalyzer.IsIssueForActiveRule(message, rulesConfig).Should().BeFalse();

            // 4. No match
            message = new Message("xxx", "filename", 0, 0, 0, 0, "msg", false, null);
            CLangAnalyzer.IsIssueForActiveRule(message, rulesConfig).Should().BeFalse();
        }