public void Accept_MultipleCallsToAccept_IssuesAreAccumulated() { var callbackSpy = new OnIssuesChangedCallbackSpy(); var firstSetOfIssues = new[] { CreateIssue(1, 1), CreateIssue(2, 2) }; var secondSetOfIssues = new[] { CreateIssue(3, 3), CreateIssue(4, 4) }; var snapshot = CreateSnapshot(lineCount: 10); var converter = CreatePassthroughConverter(); var testSubject = new AccumulatingIssueConsumer(snapshot, ValidFilePath, callbackSpy.Callback, converter); // 1. First call testSubject.Accept(ValidFilePath, firstSetOfIssues); callbackSpy.CallCount.Should().Be(1); callbackSpy.LastSuppliedIssues.Should().BeEquivalentTo(firstSetOfIssues); // 2. Second call testSubject.Accept(ValidFilePath, secondSetOfIssues); callbackSpy.CallCount.Should().Be(2); callbackSpy.LastSuppliedIssues.Should().BeEquivalentTo(firstSetOfIssues.Union(secondSetOfIssues)); }
[DataRow(11, 11, false)] // end is outside snapshot public void Accept_IssuesNotInSnapshotAreIgnored_CallbackIsCalledWithExpectedIssues(int issueStartLine, int issueEndLine, bool isMappableToSnapshot) { // Issues are 1-based. // Snapshots are 0-based so last line = index 9 const int LinesInSnapshot = 10; var snapshot = CreateSnapshot(LinesInSnapshot); var issues = new[] { CreateIssue(issueStartLine, issueEndLine) }; var callbackSpy = new OnIssuesChangedCallbackSpy(); var converter = CreatePassthroughConverter(); var testSubject = new AccumulatingIssueConsumer(snapshot, ValidFilePath, callbackSpy.Callback, converter); using (new AssertIgnoreScope()) { testSubject.Accept(ValidFilePath, issues); } callbackSpy.CallCount.Should().Be(1); if (isMappableToSnapshot) { callbackSpy.LastSuppliedIssues.Should().BeEquivalentTo(issues); } else { callbackSpy.LastSuppliedIssueVisualizations.Should().BeEmpty(); } }
public void Accept_WrongFile_CallbackIsNotCalled() { var callbackSpy = new OnIssuesChangedCallbackSpy(); var issues = new IAnalysisIssue[] { ValidIssue }; var testSubject = new AccumulatingIssueConsumer(ValidTextSnapshot, "c:\\file1.txt", callbackSpy.Callback, ValidConverter); using (new AssertIgnoreScope()) { testSubject.Accept("wrong file", issues); } callbackSpy.CallCount.Should().Be(0); }