public TextBufferIssueTracker(DTE dte, TaggerProvider provider, ITextDocument document,
                                      IEnumerable <AnalysisLanguage> detectedLanguages, IIssuesFilter issuesFilter,
                                      ISonarErrorListDataSource sonarErrorDataSource, IAnalysisIssueVisualizationConverter converter,
                                      IVsSolution5 vsSolution, ILogger logger)
        {
            this.dte = dte;

            this.Provider   = provider;
            this.textBuffer = document.TextBuffer;

            this.detectedLanguages    = detectedLanguages;
            this.sonarErrorDataSource = sonarErrorDataSource;
            this.converter            = converter;
            this.vsSolution           = vsSolution;
            this.logger       = logger;
            this.issuesFilter = issuesFilter;

            this.document = document;
            this.FilePath = document.FilePath;
            this.charset  = document.Encoding.WebName;

            this.Factory = new IssuesSnapshotFactory(new IssuesSnapshot(GetProjectName(), GetProjectGuid(), FilePath, new List <IAnalysisIssueVisualization>()));

            document.FileActionOccurred += SafeOnFileActionOccurred;

            sonarErrorDataSource.AddFactory(this.Factory);
            Provider.AddIssueTracker(this);

            RequestAnalysis(null /* no options */);
        }
        public void HandleFileRenames_OnlyAnalyzedFileRenamed_SnapshotUpdated()
        {
            var location1 = CreateLocation("file1");
            var location2 = CreateLocation("file2");
            var snapshot  = CreateIssuesSnapshot("file3", location1, location2);

            var renames = new Dictionary <string, string>
            {
                { "file3", "new file3" }
            };

            var updatedSnapshot = CreateIssuesSnapshot("new file3");

            snapshot.Setup(x => x.CreateUpdatedSnapshot("new file3")).Returns(updatedSnapshot.Object);

            var testSubject = new IssuesSnapshotFactory(snapshot.Object);

            var result = testSubject.HandleFileRenames(renames);

            result.Should().BeTrue();

            testSubject.CurrentSnapshot.Should().Be(updatedSnapshot.Object);

            location1.CurrentFilePath.Should().Be("file1");
            location2.CurrentFilePath.Should().Be("file2");

            snapshot.Verify(x => x.IncrementVersion(), Times.Never);
            updatedSnapshot.Verify(x => x.IncrementVersion(), Times.Never);
        }
        public void GetCurrentSnapshot_ReturnsCurrentSnapshot()
        {
            var location    = CreateLocation("some file1");
            var snapshot    = CreateIssuesSnapshot("some file2", location);
            var testSubject = new IssuesSnapshotFactory(snapshot.Object);

            testSubject.GetCurrentSnapshot().Should().Be(snapshot.Object);

            var updatedSnapshot = CreateIssuesSnapshot("new file3");

            testSubject.UpdateSnapshot(updatedSnapshot.Object);

            testSubject.GetCurrentSnapshot().Should().Be(updatedSnapshot.Object);
        }
        public void CurrentVersionNumber_ReturnsCurrentSnapshotVersion()
        {
            var location = CreateLocation("some file1");
            var snapshot = CreateIssuesSnapshot("some file2", location);

            snapshot.SetupGet(x => x.VersionNumber).Returns(1234);

            var testSubject = new IssuesSnapshotFactory(snapshot.Object);

            testSubject.CurrentVersionNumber.Should().Be(1234);

            snapshot.SetupGet(x => x.VersionNumber).Returns(5678);

            testSubject.CurrentVersionNumber.Should().Be(5678);
        }
        public void HandleFileRenames_NoReferencesToToRenamedFile_NoChanges()
        {
            var location = CreateLocation("some file1");
            var snapshot = CreateIssuesSnapshot("some file2", location);

            var testSubject = new IssuesSnapshotFactory(snapshot.Object);

            var result = testSubject.HandleFileRenames(new Dictionary <string, string> {
                { "old file", "new file" }
            });

            result.Should().BeFalse();

            testSubject.CurrentSnapshot.Should().Be(snapshot.Object);
            location.CurrentFilePath.Should().Be("some file1");

            snapshot.Verify(x => x.IncrementVersion(), Times.Never);
            snapshot.Verify(x => x.CreateUpdatedSnapshot(It.IsAny <string>()), Times.Never);
        }
예제 #6
0
 private void CheckErrorListRefreshWasRequestedOnce(IssuesSnapshotFactory factory)
 {
     mockSonarErrorDataSource.Verify(x => x.RefreshErrorList(factory), Times.Once);
 }
예제 #7
0
 private void CheckFactoryWasUnregisteredFromDataSource(IssuesSnapshotFactory factory, Times times)
 {
     mockSonarErrorDataSource.Verify(x => x.RemoveFactory(factory), times);
 }
예제 #8
0
 private void CheckFactoryWasRegisteredWithDataSource(IssuesSnapshotFactory factory, Times times)
 {
     mockSonarErrorDataSource.Verify(x => x.AddFactory(factory), times);
 }