public async Task HandleRequestAsync_NoDiagnosticsAfterFiltering_ReturnsNullDiagnostic() { // Arrange var called = false; var documentManager = CreateDocumentManager(); var filteredDiagnostic = new Diagnostic() { Range = new Range() { Start = new Position(159, 19), End = new Position(159, 23) }, Code = "RemoveUnnecessaryImportsFixable", Severity = DiagnosticSeverity.Warning }; var filteredDiagnostic_mappedRange = new Range() { Start = new Position(49, 19), End = new Position(49, 23) }; var diagnosticReport = new VSInternalDiagnosticReport() { ResultId = "6", Diagnostics = new Diagnostic[] { filteredDiagnostic } }; var requestInvoker = GetRequestInvoker <VSInternalDocumentDiagnosticsParams, VSInternalDiagnosticReport[]>( new[] { diagnosticReport }, (textBuffer, method, diagnosticParams, ct) => { Assert.Equal(VSInternalMethods.DocumentPullDiagnosticName, method); called = true; }); var diagnosticsProvider = GetDiagnosticsProvider(filteredDiagnostic_mappedRange); var documentSynchronizer = CreateDocumentSynchronizer(); var documentDiagnosticsHandler = new DocumentPullDiagnosticsHandler(requestInvoker, documentManager, documentSynchronizer, diagnosticsProvider, LoggerProvider); var diagnosticRequest = new VSInternalDocumentDiagnosticsParams() { TextDocument = new TextDocumentIdentifier() { Uri = Uri }, PreviousResultId = "4" }; // Act var result = await documentDiagnosticsHandler.HandleRequestAsync(diagnosticRequest, new ClientCapabilities(), CancellationToken.None).ConfigureAwait(false); // Assert Assert.True(called); var returnedReport = Assert.Single(result); Assert.Equal(diagnosticReport.ResultId, returnedReport.ResultId); Assert.Empty(returnedReport.Diagnostics); }
public async Task HandleRequestAsync_RemapFailsButErrorDiagnosticIsShown() { // Arrange var called = false; var documentManager = CreateDocumentManager(); var unmappableDiagnostic_errorSeverity = new Diagnostic() { Range = new Range() { Start = new Position(149, 19), End = new Position(149, 23) }, Code = "CS0103", Severity = DiagnosticSeverity.Error }; var unmappableDiagnostic_warningSeverity = new Diagnostic() { Range = new Range() { Start = new Position(159, 19), End = new Position(159, 23) }, Code = "IDE003", Severity = DiagnosticSeverity.Warning }; var diagnosticReport = new VSInternalDiagnosticReport() { ResultId = "6", Diagnostics = new Diagnostic[] { unmappableDiagnostic_errorSeverity, unmappableDiagnostic_warningSeverity } }; var requestInvoker = GetRequestInvoker <VSInternalDocumentDiagnosticsParams, VSInternalDiagnosticReport[]>( new[] { diagnosticReport }, (textBuffer, method, diagnosticParams, ct) => { Assert.Equal(VSInternalMethods.DocumentPullDiagnosticName, method); called = true; }); var undefinedRange = new Range() { Start = new Position(-1, -1), End = new Position(-1, -1) }; var diagnosticsProvider = GetDiagnosticsProvider(undefinedRange, undefinedRange); var documentSynchronizer = CreateDocumentSynchronizer(); var documentDiagnosticsHandler = new DocumentPullDiagnosticsHandler(requestInvoker, documentManager, documentSynchronizer, diagnosticsProvider, LoggerProvider); var diagnosticRequest = new VSInternalDocumentDiagnosticsParams() { TextDocument = new TextDocumentIdentifier() { Uri = Uri }, PreviousResultId = "4" }; // Act var result = await documentDiagnosticsHandler.HandleRequestAsync(diagnosticRequest, new ClientCapabilities(), CancellationToken.None).ConfigureAwait(false); // Assert Assert.True(called); var diagnosticReportResult = Assert.Single(result); Assert.Equal(diagnosticReport.ResultId, diagnosticReportResult.ResultId); var returnedDiagnostic = Assert.Single(diagnosticReportResult.Diagnostics); Assert.Equal(unmappableDiagnostic_errorSeverity.Code, returnedDiagnostic.Code); Assert.True(returnedDiagnostic.Range.IsUndefined()); }