public void GetIssues_ErrorInInitialFetchTask_IsSuppressed() { var issue1 = new SonarQubeIssue("folder1/file1", "hash1", 0, "message", "sqkey:sqkey:projectID1", SonarQubeIssueResolutionState.FalsePositive, "S101"); Func <IList <SonarQubeIssue> > serviceFetchIssuesTask = () => { InitialFetchWaitHandle.Set(); // signal so the test can continue throw new ApplicationException("dummy error from mock"); }; SetupSolutionBinding(isConnected: true, serviceFetchIssuesTask: serviceFetchIssuesTask); // 1. Create the issue provider // The initial fetch should be triggered, but not yet completed var issuesProvider = new SonarQubeIssuesProvider(mockSqService.Object, "sqkey", mockTimerFactory.Object, testLogger); WaitForInitialFetchTaskToStart(); // 2. Now request the issues - task completes with an error var matches = issuesProvider.GetSuppressedIssues("projectid1", "folder1/file1"); VerifyServiceGetIssues(Times.Once(), "sqkey"); matches.Should().BeEmpty(); // 3. Now fetch again - should not wait again, should not error matches = issuesProvider.GetSuppressedIssues("folder1/file1", "projectid1"); matches.Should().BeEmpty(); VerifyServiceGetIssues(Times.Once()); testLogger.AssertPartialOutputStrings("Checking for suppressions", "dummy error from mock"); }
public void CallAnalyzer_BadResponse_FailsSilentlyAndReturnsNull() { // Arrange var logger = new TestLogger(); var dummyProcessRunner = new DummyProcessRunner(MockBadEndResponse(), true); var result = CFamilyHelper.CallClangAnalyzer(new Request(), dummyProcessRunner, logger, CancellationToken.None); // Act and Assert result.Should().BeNull(); logger.AssertPartialOutputStrings("Failed to execute analysis"); dummyProcessRunner.ExecuteCalled.Should().BeTrue(); File.Exists(dummyProcessRunner.ExchangeFileName).Should().BeFalse(); }