public void WhenNewIssuesAreFound_FileHasNoAssociatedProject_NoExceptionIsThrown() { mockSolution.Reset(); mockSolution .Setup(x => x.FindProjectItem(mockedJavascriptDocumentFooJs.Name)) .Returns((ProjectItem)null); testSubject = CreateTextBufferIssueTracker(); Action act = () => testSubject.HandleNewIssues(new List <IAnalysisIssueVisualization>()); act.Should().NotThrow(); }
public void WhenNewIssuesAreFound_FilterIsApplied_ListenersAreUpdated() { // Arrange // Use the test version of the text buffer to bypass the span translation code testSubject = new TestableTextBufferIssueTracker(taggerProvider.dte, taggerProvider, mockedJavascriptDocumentFooJs.Object, javascriptLanguage, issuesFilter.Object, mockSonarErrorDataSource.Object, Mock.Of <IAnalysisIssueVisualizationConverter>(), Mock.Of <IVsSolution5>(), logger); mockSonarErrorDataSource.Invocations.Clear(); var originalId = testSubject.Factory.CurrentSnapshot.AnalysisRunId; var inputIssues = new[] { CreateIssue("S111", startLine: 1, endLine: 1), CreateIssue("S222", startLine: 2, endLine: 2) }; var issuesToReturnFromFilter = new[] { CreateIssue("xxx", startLine: 3, endLine: 3) }; SetupIssuesFilter(out var issuesPassedToFilter, issuesToReturnFromFilter); // Act testSubject.HandleNewIssues(inputIssues); // Assert // Check the snapshot has changed testSubject.Factory.CurrentSnapshot.AnalysisRunId.Should().NotBe(originalId); // Check the expected issues were passed to the filter issuesPassedToFilter.Count.Should().Be(2); issuesPassedToFilter.Should().BeEquivalentTo(inputIssues, c => c.WithStrictOrdering()); CheckErrorListRefreshWasRequestedOnce(testSubject.Factory); // Check the post-filter issues testSubject.Factory.CurrentSnapshot.Issues.Count().Should().Be(1); testSubject.Factory.CurrentSnapshot.Issues.First().Issue.RuleKey.Should().Be("xxx"); testSubject.Factory.CurrentSnapshot.TryGetValue(0, StandardTableKeyNames.ProjectName, out var projectName).Should().BeTrue(); projectName.Should().Be("MyProject"); testSubject.Factory.CurrentSnapshot.TryGetValue(0, StandardTableKeyNames.ProjectGuid, out var projectGuid).Should().BeTrue(); projectGuid.Should().Be(projectGuid); }