public void SetUp() { var path = "foo.js"; issue = new Issue() { FilePath = path, Message = "This is dangerous", RuleKey = "javascript:123", Severity = Issue.Types.Severity.Blocker, }; var mockTextSnap = new Mock <ITextSnapshot>(); mockTextSnap.Setup(t => t.Length).Returns(50); var mockTextSnapLine = new Mock <ITextSnapshotLine>(); mockTextSnapLine.Setup(l => l.LineNumber).Returns(12); mockTextSnapLine.Setup(l => l.Start).Returns(new SnapshotPoint(mockTextSnap.Object, 10)); mockTextSnap.Setup(t => t.GetLineFromPosition(25)).Returns(mockTextSnapLine.Object); var textSnap = mockTextSnap.Object; var marker = new IssueMarker(issue, new SnapshotSpan(new SnapshotPoint(textSnap, 25), new SnapshotPoint(textSnap, 27))); snapshot = new IssuesSnapshot("MyProject", path, 1, new List <IssueMarker>() { marker }); }
public void IndexOf_NotAnIssuesSnapshot_ReturnsMinusOne() { var original = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); original.IndexOf(999, Mock.Of <ITableEntriesSnapshot>()) .Should().Be(IndexOf_NotFoundResult); }
public void SetUp() { var path = "foo.js"; issue = new DummyAnalysisIssue { FilePath = path, Message = "This is dangerous", RuleKey = "javascript:123", Severity = AnalysisIssueSeverity.Blocker, }; projectGuid = Guid.NewGuid(); var mockTextSnap = new Mock <ITextSnapshot>(); mockTextSnap.Setup(t => t.Length).Returns(50); var mockTextSnapLine = new Mock <ITextSnapshotLine>(); mockTextSnapLine.Setup(l => l.LineNumber).Returns(12); mockTextSnapLine.Setup(l => l.Start).Returns(new SnapshotPoint(mockTextSnap.Object, 10)); mockTextSnap.Setup(t => t.GetLineFromPosition(25)).Returns(mockTextSnapLine.Object); var textSnap = mockTextSnap.Object; issueViz = CreateIssueViz(issue, new SnapshotSpan(new SnapshotPoint(textSnap, 25), new SnapshotPoint(textSnap, 27))); snapshot = new IssuesSnapshot("MyProject", projectGuid, path, new List <IAnalysisIssueVisualization> { issueViz }); }
public void Construction_CreateNew_SetsUniqueId() { var snapshot1 = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); var snapshot2 = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); snapshot1.AnalysisRunId.Should().NotBe(snapshot2.AnalysisRunId); snapshot2.VersionNumber.Should().BeGreaterThan(snapshot1.VersionNumber); }
public void Count_ReturnsNumberOfIssues(int numberOfIssues) { var analysisIssueVisualizations = Enumerable.Repeat(issueViz, numberOfIssues); var testSubject = new IssuesSnapshot("MyProject", Guid.Empty, "foo.js", analysisIssueVisualizations); testSubject.Count.Should().Be(numberOfIssues); }
public void IndexOf_DifferentSnapshotId_ReturnMinusOne() { var snapshot1 = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); var snapshot2 = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); // Should not be able to map issues between two snapshots with different snapshot ids snapshot1.IndexOf(999, snapshot2) .Should().Be(IndexOf_NotFoundResult); }
public void IndexOf_SameSnapshotId_ReturnExpectedIndex() { var original = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); var revised = original.CreateUpdatedSnapshot("unimportant change"); // Should be able to map issues between two snapshots with the same snapshot id original.IndexOf(999, revised) .Should().Be(999); }
public void IndexOf_IfIndexOutOfRange_ReturnsNotFound(int inputIndex, int expected) { var original = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, new[] { CreateIssue(), CreateIssue(), CreateIssue() }); var modified = original.CreateUpdatedSnapshot("unimportant change"); // Should not be able to map to an out-of-range index original.IndexOf(inputIndex, modified) .Should().Be(expected); }
public void Construction_CreateNew_SetsProperties() { var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); testSubject.AnalysisRunId.Should().NotBe(Guid.Empty); testSubject.VersionNumber.Should().BeGreaterOrEqualTo(0); GetProjectName(testSubject).Should().BeEquivalentTo(ValidProjectName); GetProjectGuid(testSubject).Should().Be(ValidProjectGuid); GetFilePath(testSubject).Should().BeEquivalentTo(ValidFilePath); testSubject.Issues.Should().BeEquivalentTo(ValidIssueList); }
public void GetLocationsVizForFile_NoMatches_ReturnsEmpty() { var issue1 = CreateIssueWithSpecificsPaths("path1.txt"); var issues = new[] { issue1 }; var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, issues); var actual = testSubject.GetLocationsVizsForFile("xxx"); actual.Should().BeEmpty(); }
public void IncrementVersion_VersionIncrement_AnalysisIdAndIssuesUnchanged() { var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidProjectName, ValidIssueList); var originalVersion = testSubject.VersionNumber; var originalRunId = testSubject.AnalysisRunId; testSubject.IncrementVersion(); testSubject.VersionNumber.Should().BeGreaterThan(originalVersion); testSubject.AnalysisRunId.Should().Be(originalRunId); testSubject.Issues.Should().BeEquivalentTo(ValidIssueList); }
public void IndexOf_NewIssueDoesNotHaveValidSpan_ReturnNotFound() { var span = CreateIssue(); var snapshot1 = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, new[] { span }); var snapshot2 = snapshot1.CreateUpdatedSnapshot("unimportant change"); span.InvalidateSpan(); // Should not be able to map to an issue with an invalid span since it should be hidden snapshot1.IndexOf(0, snapshot2) .Should().Be(IndexOf_NotFoundResult); }
public void GetLocationsVizForFile_MatchesInPrimaryLocations_ReturnsExpected() { var issue1 = CreateIssueWithSpecificsPaths("path1.txt"); var issue2 = CreateIssueWithSpecificsPaths("XXX.txt"); var issue3 = CreateIssueWithSpecificsPaths("path1.txt"); var issues = new[] { issue1, issue2, issue3 }; var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, issues); var actual = testSubject.GetLocationsVizsForFile("path1.txt"); actual.Should().BeEquivalentTo(issue1, issue3); }
public void Construction_UpdateFilePath_PreservesIdAndUpdatesVersion() { var original = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, ValidIssueList); var revised = original.CreateUpdatedSnapshot("new path"); revised.AnalysisRunId.Should().Be(original.AnalysisRunId); revised.VersionNumber.Should().BeGreaterThan(original.VersionNumber); GetFilePath(original).Should().Be(ValidFilePath); GetFilePath(revised).Should().Be("new path"); // Other properties revised.Issues.Should().BeEquivalentTo(original.Issues); GetProjectName(revised).Should().Be(GetProjectName(original)); GetProjectGuid(revised).Should().Be(GetProjectGuid(original)); }
public void GetLocationsVizForFile_MatchesInSecondaryLocations_ReturnsExpected() { var flow1 = CreateFlowViz("match.txt", "MATCH.TXT"); var flow2 = CreateFlowViz("miss.txt", "Match.txt"); var flow3 = CreateFlowViz("another miss.txt"); var issue1 = CreateIssueWithSpecificsPaths("path1.txt", flow1, flow2, flow3); var issues = new[] { issue1 }; var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, ValidFilePath, issues); var actual = testSubject.GetLocationsVizsForFile("match.txt"); actual.Should().BeEquivalentTo(flow1.Locations[0], flow1.Locations[1], flow2.Locations[1]); }
public void Construction_CreateNew_FilesInSnapshotIsSetCorrectly() { var issue1 = CreateIssueWithSpecificsPaths("path1", // primary location CreateFlowViz("path2"), // flow with one secondary location CreateFlowViz("path3", "path4", "PATH1")); // flow with multiple secondary locations, including one duplicate in a different case var issue2 = CreateIssueWithSpecificsPaths("path5"); // new primary location, no flows var issue3 = CreateIssueWithSpecificsPaths("path2"); // duplicate primary location, no flows var issues = new[] { issue1, issue2, issue3 }; var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, "analyzedFilePath.txt", issues); testSubject.FilesInSnapshot.Should().BeEquivalentTo("path1", "path2", "path3", "path4", "path5", "analyzedFilePath.txt"); }
public void SetUp() { var path = "foo.js"; issue = new Issue() { FilePath = path, Message = "This is dangerous", RuleKey = "javascript:123", Severity = Issue.Types.Severity.Blocker, }; var marker = new IssueMarker(issue, new SnapshotSpan()); snapshot = new IssuesSnapshot(path, 1, new List <IssueMarker>() { marker }); }
public void Construction_CreateNew_NoLocations_FilesInSnapshotIsSetCorrectly() { var testSubject = new IssuesSnapshot(ValidProjectName, ValidProjectGuid, "analyzedFilePath.txt", Array.Empty <IAnalysisIssueVisualization>()); testSubject.FilesInSnapshot.Should().BeEquivalentTo("analyzedFilePath.txt"); }