private void HasDiagnostic(Document document, string diagnosticId, IDiagnosticLocator locator) { var reporteddiagnostics = GetDiagnostics(document).Where(d => locator.Match(d.Location)).ToArray(); var matchedDiagnostics = reporteddiagnostics.Count(d => d.Id == diagnosticId); if (matchedDiagnostics == 0) { throw RoslynTestKitException.DiagnosticNotFound(diagnosticId, locator, reporteddiagnostics); } }
private void TestCodeFix(Document document, string expected, string diagnosticId, IDiagnosticLocator locator, int codeFixIndex) { var reportedDiagnostics = GetReportedDiagnostics(document, locator).ToArray(); var diagnostic = reportedDiagnostics.FirstOrDefault(x => x.Id == diagnosticId); if (diagnostic == null) { throw RoslynTestKitException.DiagnosticNotFound(diagnosticId, locator, reportedDiagnostics); } TestCodeFix(document, expected, diagnostic.Descriptor, locator, codeFixIndex); }
private Diagnostic GetDiagnostic(Document document, string diagnosticId, IDiagnosticLocator locator) { var reportedDiagnostics = GetReportedDiagnostics(document, locator).ToArray(); var diagnostic = reportedDiagnostics.FirstOrDefault(x => x.Id == diagnosticId); if (diagnostic == null) { throw RoslynTestKitException.DiagnosticNotFound(diagnosticId, locator, reportedDiagnostics); } return(diagnostic); }