Skip to content

Commit 92d66c6

Browse files
Improve coverage for SA1110 by adding tests for attributes with qualified names
1 parent 7885adb commit 92d66c6

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1110UnitTests.cs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -603,31 +603,33 @@ public void Bar()
603603
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
604604
}
605605

606-
[Fact]
607-
public async Task TestAttributeOpeningParenthesisOnTheNextLineAsync()
606+
[Theory]
607+
[InlineData("Conditional")]
608+
[InlineData("System.Diagnostics.Conditional")]
609+
public async Task TestAttributeOpeningParenthesisOnTheNextLineAsync(string attributeName)
608610
{
609-
var testCode = @"
611+
var testCode = $@"
610612
using System.Diagnostics;
611613
public class Foo
612-
{
613-
[Conditional
614-
(""DEBUG""), Conditional
614+
{{
615+
[{attributeName}
616+
(""DEBUG""), {attributeName}
615617
(""TEST1"")]
616618
public void Baz()
617-
{
618-
}
619-
}";
620-
var fixedCode = @"
619+
{{
620+
}}
621+
}}";
622+
var fixedCode = $@"
621623
using System.Diagnostics;
622624
public class Foo
623-
{
624-
[Conditional(
625-
""DEBUG""), Conditional(
625+
{{
626+
[{attributeName}(
627+
""DEBUG""), {attributeName}(
626628
""TEST1"")]
627629
public void Baz()
628-
{
629-
}
630-
}";
630+
{{
631+
}}
632+
}}";
631633

632634
DiagnosticResult[] expected =
633635
{
@@ -638,19 +640,21 @@ public void Baz()
638640
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
639641
}
640642

641-
[Fact]
642-
public async Task TestAttributeOpeningParenthesisOnTheSameLineAsync()
643+
[Theory]
644+
[InlineData("Conditional")]
645+
[InlineData("System.Diagnostics.Conditional")]
646+
public async Task TestAttributeOpeningParenthesisOnTheSameLineAsync(string attributeName)
643647
{
644-
var testCode = @"
648+
var testCode = $@"
645649
using System.Diagnostics;
646650
public class Foo
647-
{
648-
[Conditional(""DEBUG""), Conditional(""TEST1"")]
651+
{{
652+
[{attributeName}(""DEBUG""), {attributeName}(""TEST1"")]
649653
public void Baz()
650-
{
654+
{{
651655
652-
}
653-
}";
656+
}}
657+
}}";
654658

655659
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
656660
}

0 commit comments

Comments
 (0)