Exemple #1
0
        public static void UpdateWithDiagnostics()
        {
            var style = new CSharpPreferredModifierOrderStyle(new ModifierData());

            var statement = (MethodDeclarationSyntax)SyntaxFactory.ParseCompilationUnit(
                @"public class Foo
{
	public static void Bar()=> { }
}", options: Shared.ParseOptions).DescendantNodes().Single(_ => _.Kind() == SyntaxKind.MethodDeclaration);
            var newStyle = style.Update(statement);

            var data = newStyle.Data;

            Assert.That(newStyle, Is.Not.SameAs(style), nameof(newStyle));
            Assert.That(data.TotalOccurences, Is.EqualTo(0u), nameof(data.TotalOccurences));
            Shared.VerifyModifiers(data.VisibilityModifiers);
            Shared.VerifyModifiers(data.OtherModifiers);
        }
Exemple #2
0
        public static void UpdateWithVisibilityAndOtherModifierSpecified()
        {
            var style = new CSharpPreferredModifierOrderStyle(new ModifierData());

            var statement = (MethodDeclarationSyntax)SyntaxFactory.ParseCompilationUnit(
                @"public class Foo
{
	public static void Bar() { }
}", options: Shared.ParseOptions).DescendantNodes().Single(_ => _.Kind() == SyntaxKind.MethodDeclaration);
            var newStyle = style.Update(statement);

            var data = newStyle.Data;

            Assert.That(newStyle, Is.Not.SameAs(style), nameof(newStyle));
            Assert.That(data.TotalOccurences, Is.EqualTo(2u), nameof(data.TotalOccurences));

            Shared.VerifyModifiers(data.VisibilityModifiers,
                                   new KeyValuePair <string, (uint weight, uint frequency)>(
                                       SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText, (2u, 1u)));
            Shared.VerifyModifiers(data.OtherModifiers,
                                   new KeyValuePair <string, (uint weight, uint frequency)>(
                                       SyntaxFactory.Token(SyntaxKind.StaticKeyword).ValueText, (1u, 1u)));
        }