Esempio n. 1
0
        public void CreateFilterableIssue_IssueLineOutsideSnapshot_ReturnsNull(int issueStartLine, int bufferLineCount)
        {
            // Arrange
            var issue = new Sonarlint.Issue {
                StartLine = issueStartLine
            };
            var mockSnapshot = CreateMockTextSnapshot(bufferLineCount, "unimportant");

            // Act and assert
            IssueToFilterableIssueConverter.CreateFilterableIssue(issue, mockSnapshot.Object)
            .Should().BeNull();
        }
Esempio n. 2
0
        public void CreateFilterableIssue_IssueLineInSnapshot_ReturnsFilterableIssue(int issueStartLine, int bufferLineCount)
        {
            var issue = new Sonarlint.Issue {
                StartLine = issueStartLine
            };
            var mockSnapshot = CreateMockTextSnapshot(bufferLineCount, "some text");

            // Act
            var actual = IssueToFilterableIssueConverter.CreateFilterableIssue(issue, mockSnapshot.Object);

            // Assert
            actual.Should().BeOfType(typeof(DaemonIssueAdapter));

            var adapterIssue = (DaemonIssueAdapter)actual;

            adapterIssue.SonarLintIssue.Should().BeSameAs(issue);

            actual.WholeLineText.Should().Be("some text");
            actual.LineHash.Should().Be(ChecksumCalculator.Calculate("some text"));
        }
Esempio n. 3
0
        public void CreateFilterableIssue_FileLevelIssue_ReturnsFilterableIssue()
        {
            // Arrange
            var issue = new Sonarlint.Issue {
                StartLine = 0
            };
            var mockSnapshot = CreateMockTextSnapshot(10, "anything");

            // Act
            var actual = IssueToFilterableIssueConverter.CreateFilterableIssue(issue, mockSnapshot.Object);

            // Assert
            actual.Should().BeOfType(typeof(DaemonIssueAdapter));
            var adapterIssue = (DaemonIssueAdapter)actual;

            adapterIssue.SonarLintIssue.Should().BeSameAs(issue);

            actual.StartLine.Should().Be(0);
            actual.WholeLineText.Should().BeNull();
            actual.LineHash.Should().BeNull();
        }