public static (string firstFileContent, Maybe <string> secondFileContent) ApplyRefactoring(
            string content,
            Func <SyntaxNode, TextSpan> spanSelector,
            Maybe <string> refactoringName,
            bool shouldThereBeRefactorings,
            Maybe <string> secondFileContent,
            params MetadataReference[] additionalReferences)
        {
            var workspace = new AdhocWorkspace();

            var solution = workspace.CurrentSolution;

            var projectId = ProjectId.CreateNewId();

            solution = AddNewProjectToWorkspace(solution, "NewProject", projectId, additionalReferences);

            var documentId = DocumentId.CreateNewId(projectId);

            solution = AddNewSourceFile(solution, content, "NewFile.cs", documentId);

            Maybe <DocumentId> document2Id = default;

            if (secondFileContent.HasValue)
            {
                document2Id = DocumentId.CreateNewId(projectId);

                solution = AddNewSourceFile(solution, secondFileContent.GetValue(), "NewFile2.cs", document2Id.GetValue());
            }

            var document = solution.GetDocument(documentId);

            var syntaxNode = document.GetSyntaxRootAsync().Result;

            var span = spanSelector(syntaxNode);

            var refactoringActions = new List <CodeAction>();

            var refactoringContext =
                new CodeRefactoringContext(
                    document,
                    span,
                    action => refactoringActions.Add(action),
                    CancellationToken.None);

            var sut = new DependencyInjectionHelperCodeRefactoringProvider();

            sut.ComputeRefactoringsAsync(refactoringContext).Wait();


            if (!shouldThereBeRefactorings)
            {
                if (refactoringActions.Count > 0)
                {
                    throw new Exception("Some refactoring actions found");
                }

                return(content, secondFileContent);
            }


            if (refactoringActions.Count == 0)
            {
                throw new Exception("No refactoring actions found");
            }


            refactoringActions.ForEach(action =>
            {
                if (refactoringName.HasNoValue || action.Title == refactoringName.GetValue())
                {
                    var operations = action.GetOperationsAsync(CancellationToken.None).Result;

                    foreach (var operation in operations)
                    {
                        operation.Apply(workspace, CancellationToken.None);
                    }
                }
            });

            var updatedDocument = workspace.CurrentSolution.GetDocument(documentId);

            var updatedSecondDocument = document2Id
                                        .ChainValue(x => workspace.CurrentSolution.GetDocument(x));

            var updatedDocumentContent = updatedDocument.GetSyntaxRootAsync().Result.GetText().ToString();

            var updatedSecondDocumentContent =
                updatedSecondDocument.ChainValue(x => x.GetSyntaxRootAsync().Result.GetText().ToString());

            return(updatedDocumentContent, updatedSecondDocumentContent);
        }