public async Task VerifyGetFixesWhenClassIsSealed()
        {
            var code = File.ReadAllText(
                $@"Targets\{nameof(IsOperationMethodPublicMakeNonPublicCodeFixTests)}\{(nameof(this.VerifyGetFixesWhenClassIsSealed))}.cs");
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new IsOperationMethodPublicAnalyzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new IsOperationMethodPublicMakeNonPublicCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(2, actions.Count);
            await TestHelpers.VerifyActionAsync(actions,
                                                IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.PrivateDescription, document,
                                                tree, new[] { "rivate" });

            await TestHelpers.VerifyActionAsync(actions,
                                                IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.InternalDescription, document,
                                                tree, new[] { "internal" });
        }
        public void VerifyGetFixableDiagnosticIds()
        {
            var fix = new IsOperationMethodPublicMakeNonPublicCodeFix();
            var ids = fix.FixableDiagnosticIds.ToList();

            Assert.AreEqual(1, ids.Count, nameof(ids.Count));
            Assert.AreEqual(IsOperationMethodPublicAnalyzerConstants.DiagnosticId, ids[0],
                            nameof(IsOperationMethodPublicAnalyzerConstants.DiagnosticId));
        }
        public async Task VerifyGetFixesWhenClassIsNotSealed()
        {
            var code =
                @"using Csla;
using System;

[Serializable]
public class A : BusinessBase<A>
{
  [Fetch]
  public void Fetch() { }
}";
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new IsOperationMethodPublicAnalyzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new IsOperationMethodPublicMakeNonPublicCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(3, actions.Count);

            await TestHelpers.VerifyChangesAsync(actions,
                                                 IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.PrivateDescription, document,
                                                 (model, newRoot) =>
            {
                var methodNode   = newRoot.DescendantNodes(_ => true).OfType <MethodDeclarationSyntax>().Single();
                var methodSymbol = model.GetDeclaredSymbol(methodNode) as IMethodSymbol;
                Assert.AreEqual(Accessibility.Private, methodSymbol.DeclaredAccessibility);
            });

            await TestHelpers.VerifyChangesAsync(actions,
                                                 IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.ProtectedDescription, document,
                                                 (model, newRoot) =>
            {
                var methodNode   = newRoot.DescendantNodes(_ => true).OfType <MethodDeclarationSyntax>().Single();
                var methodSymbol = model.GetDeclaredSymbol(methodNode) as IMethodSymbol;
                Assert.AreEqual(Accessibility.Protected, methodSymbol.DeclaredAccessibility);
            });

            await TestHelpers.VerifyChangesAsync(actions,
                                                 IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.InternalDescription, document,
                                                 (model, newRoot) =>
            {
                var methodNode   = newRoot.DescendantNodes(_ => true).OfType <MethodDeclarationSyntax>().Single();
                var methodSymbol = model.GetDeclaredSymbol(methodNode) as IMethodSymbol;
                Assert.AreEqual(Accessibility.Internal, methodSymbol.DeclaredAccessibility);
            });
        }
        public async Task VerifyGetFixesWhenClassIsNotSealed()
        {
            var code =
                @"using Csla;
using System;

namespace Csla.Analyzers.Tests.Targets.IsOperationMethodPublicMakeNonPublicCodeFixTests
{
  [Serializable]
  public class VerifyGetFixesWhenClassIsNotSealed
    : BusinessBase<VerifyGetFixesWhenClassIsNotSealed>
  {
    public void DataPortal_Fetch() { }
  }
}";
            var document = TestHelpers.Create(code);
            var tree     = await document.GetSyntaxTreeAsync();

            var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new IsOperationMethodPublicAnalyzer());

            var sourceSpan = diagnostics[0].Location.SourceSpan;

            var actions = new List <CodeAction>();
            var codeActionRegistration = new Action <CodeAction, ImmutableArray <Diagnostic> >(
                (a, _) => { actions.Add(a); });

            var fix            = new IsOperationMethodPublicMakeNonPublicCodeFix();
            var codeFixContext = new CodeFixContext(document, diagnostics[0],
                                                    codeActionRegistration, new CancellationToken(false));
            await fix.RegisterCodeFixesAsync(codeFixContext);

            Assert.AreEqual(3, actions.Count);
            await TestHelpers.VerifyActionAsync(actions,
                                                IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.PrivateDescription, document,
                                                tree, new[] { "rivate" });

            await TestHelpers.VerifyActionAsync(actions,
                                                IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.ProtectedDescription, document,
                                                tree, new[] { "rotected" });

            await TestHelpers.VerifyActionAsync(actions,
                                                IsOperationMethodPublicAnalyzerMakeNonPublicCodeFixConstants.InternalDescription, document,
                                                tree, new[] { "internal" });
        }