Exemplo n.º 1
0
            public static void MakeSealed()
            {
                var before = @"
namespace N
{
    ↓public class C
    {
    }
}";

                var after    = @"
namespace N
{
    public sealed class C
    {
    }
}";
                var analyzer = new ClassMustBeSealedAnalyzer();
                var fix      = new MakeSealedFixProvider();

                RoslynAssert.CodeFix(analyzer, fix, new[] { before }, after);
                RoslynAssert.CodeFix(analyzer, fix, new[] { before }, new[] { after });
                var expectedDiagnostic = ExpectedDiagnostic.Create(ClassMustBeSealedAnalyzer.DiagnosticId);

                RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, new[] { before }, after);
                RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, new[] { before }, new[] { after });
            }
Exemplo n.º 2
0
            public static void MakeSealedCorrectFixKeepsPoorFormat()
            {
                var before = @"
namespace    N
{
    ↓public class C
    {
private readonly int value;
                
            public C(int value)
{
        this.value  =  value;
        }
    }
}";

                var after    = @"
namespace    N
{
    public sealed class C
    {
private readonly int value;
                
            public C(int value)
{
        this.value  =  value;
        }
    }
}";
                var analyzer = new ClassMustBeSealedAnalyzer();
                var fix      = new MakeSealedFixProvider();

                RoslynAssert.CodeFix(analyzer, fix, new[] { before }, after);
                RoslynAssert.CodeFix(analyzer, fix, new[] { before }, new[] { after });
                var expectedDiagnostic = ExpectedDiagnostic.Create(ClassMustBeSealedAnalyzer.DiagnosticId);

                RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, new[] { before }, after);
                RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, new[] { before }, new[] { after });
            }