public static RoslynTestKitException CodeRefactoringNotFound(ICodeActionSelector codeActionSelector, ImmutableArray <CodeAction> codeRefactorings, IDiagnosticLocator locator)
        {
            var refactoringDescriptions = GetActionsDescription(codeRefactorings, $" Found only {codeRefactorings.Length} CodeRefactorings: ");
            var message = $"Cannot find CodeRefactoring {codeActionSelector}  at {locator.Description()}.{refactoringDescriptions}";

            return(new RoslynTestKitException(message));
        }
        public static RoslynTestKitException UnexpectedCodeFixFound(ImmutableArray <CodeAction> codeFixes, IDiagnosticLocator locator)
        {
            var codeFixDescription = GetActionsDescription(codeFixes, "Reported fixes: ");
            var message            = $"Found unexpected CodeFixes at {locator.Description()}.{codeFixDescription}";

            return(new RoslynTestKitException(message));
        }
        public static RoslynTestKitException DiagnosticNotFound(string diagnosticId, IDiagnosticLocator locator, Diagnostic[] reportedDiagnostics)
        {
            var reportedDiagnosticInfo = reportedDiagnostics.MergeWithComma(x => x.Id, title: "Reported issues: ");
            var message = $"There is no issue reported for {diagnosticId} at {locator.Description()}.{reportedDiagnosticInfo}";

            return(new RoslynTestKitException(message));
        }
        public static Exception CannotFindSuggestion(IReadOnlyList <string> missingCompletion, ImmutableArray <CompletionItem> resultItems, IDiagnosticLocator locator)
        {
            var foundSuggestionDescription = resultItems.MergeAsBulletList(x => x.DisplayText, title: "\r\nFound suggestions:\r\n");

            return(new RoslynTestKitException($"Cannot get suggestions:\r\n{missingCompletion.MergeAsBulletList()}\r\nat{locator.Description()}{foundSuggestionDescription}"));
        }
        public static RoslynTestKitException CodeFixNotFound(int expectedCodeFixIndex, ImmutableArray <CodeAction> codeFixes, IDiagnosticLocator locator)
        {
            var codeFixDescription = GetActionsDescription(codeFixes, " Found only {codeFixes.Length} CodeFixes: ");
            var message            = $"Cannot find CodeFix with index {expectedCodeFixIndex} at {locator.Description()}.{codeFixDescription}";

            return(new RoslynTestKitException(message));
        }
        public static RoslynTestKitException UnexpectedDiagnostic(string diagnosticId, IDiagnosticLocator locator = null)
        {
            var description = locator != null ? $"at {locator.Description()}" : string.Empty;

            return(new RoslynTestKitException($"Found reported diagnostic '{diagnosticId}' in spite of the expectations {description}"));
        }