private void TestCodeRefactoring(Document document, string expected, IDiagnosticLocator locator, int refactoringIndex = 0)
        {
            var codeRefactorings = GetCodeRefactorings(document, locator);

            if (codeRefactorings.Length < refactoringIndex + 1)
            {
                throw RoslynTestKitException.CodeRefactoringNotFound(refactoringIndex, codeRefactorings, locator);
            }
            Verify.CodeAction(codeRefactorings[refactoringIndex], document, expected);
        }
Пример #2
0
        private void TestCodeRefactoring(Document document, string expected, IDiagnosticLocator locator, int refactoringIndex = 0)
        {
            var codeRefactorings = GetCodeRefactorings(document, locator);

            if (codeRefactorings.Length < refactoringIndex + 1)
            {
                throw RoslynTestKitException.CodeRefactoringNotFound(refactoringIndex, codeRefactorings, locator);
            }

            if (FailWhenInputContainsErrors)
            {
                var errors = document.GetErrors();
                if (errors.Count > 0)
                {
                    throw RoslynTestKitException.UnexpectedErrorDiagnostic(errors);
                }
            }

            Verify.CodeAction(codeRefactorings[refactoringIndex], document, expected);
        }
        private void TestCodeRefactoring(Document document, string expected, IDiagnosticLocator locator, ICodeActionSelector codeActionSelector)
        {
            if (FailWhenInputContainsErrors)
            {
                var errors = document.GetErrors();
                if (errors.Count > 0)
                {
                    throw RoslynTestKitException.UnexpectedErrorDiagnostic(errors);
                }
            }

            var codeRefactorings    = GetCodeRefactorings(document, locator);
            var selectedRefactoring = codeActionSelector.Find(codeRefactorings);

            if (selectedRefactoring is null)
            {
                throw RoslynTestKitException.CodeRefactoringNotFound(codeActionSelector, codeRefactorings, locator);
            }

            Verify.CodeAction(selectedRefactoring, document, expected);
        }