|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules |
5 | 5 | { |
| 6 | + using System.Threading; |
| 7 | + using System.Threading.Tasks; |
6 | 8 | using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; |
| 9 | + using StyleCop.Analyzers.Test.Helpers; |
| 10 | + using Xunit; |
| 11 | + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< |
| 12 | + StyleCop.Analyzers.ReadabilityRules.SA1137ElementsShouldHaveTheSameIndentation, |
| 13 | + StyleCop.Analyzers.ReadabilityRules.IndentationCodeFixProvider>; |
7 | 14 |
|
8 | 15 | public class SA1137CSharp10UnitTests : SA1137CSharp9UnitTests |
9 | 16 | { |
| 17 | + [Theory] |
| 18 | + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] |
| 19 | + public async Task TestFileScopedNamespaceDeclarationAsync(string baseTypeKind) |
| 20 | + { |
| 21 | + await new CSharpTest |
| 22 | + { |
| 23 | + TestSources = |
| 24 | + { |
| 25 | + $@" |
| 26 | +using System; |
| 27 | +
|
| 28 | +namespace Namespace0; |
| 29 | +
|
| 30 | + [My] [My] {baseTypeKind} TypeName {{ }} |
| 31 | +", |
| 32 | + $@" |
| 33 | +using System; |
| 34 | +
|
| 35 | +namespace Namespace1; |
| 36 | +
|
| 37 | + [My] |
| 38 | +[| |][My] {baseTypeKind} TypeName {{ }} |
| 39 | +", |
| 40 | + $@" |
| 41 | +using System; |
| 42 | +
|
| 43 | +namespace Namespace2; |
| 44 | +
|
| 45 | + [My] |
| 46 | +[| |][My] |
| 47 | + {baseTypeKind} TypeName {{ }} |
| 48 | +", |
| 49 | + $@" |
| 50 | +using System; |
| 51 | +
|
| 52 | +namespace Namespace3; |
| 53 | +
|
| 54 | +[| |][My] |
| 55 | +[| |][My] |
| 56 | + {baseTypeKind} TypeName {{ }} |
| 57 | +", |
| 58 | + $@" |
| 59 | +using System; |
| 60 | +
|
| 61 | +namespace Namespace4; |
| 62 | +
|
| 63 | + {baseTypeKind} TypeName1 {{ }} |
| 64 | +
|
| 65 | +[| |][My] {baseTypeKind} TypeName2 {{ }} |
| 66 | +", |
| 67 | + $@" |
| 68 | +using System; |
| 69 | +
|
| 70 | +namespace Namespace5; |
| 71 | +
|
| 72 | + {baseTypeKind} TypeName1 {{ }} |
| 73 | +
|
| 74 | + [My] |
| 75 | +[| |][My] {baseTypeKind} TypeName2 {{ }} |
| 76 | +", |
| 77 | + $@" |
| 78 | +using System; |
| 79 | +
|
| 80 | +namespace Namespace6; |
| 81 | +
|
| 82 | + {baseTypeKind} TypeName1 {{ }} |
| 83 | +
|
| 84 | +[| |][My] |
| 85 | + [My] {baseTypeKind} TypeName2 {{ }} |
| 86 | +", |
| 87 | + $@" |
| 88 | +using System; |
| 89 | +
|
| 90 | +[AttributeUsage(AttributeTargets.All, AllowMultiple = true)] |
| 91 | +class MyAttribute : Attribute {{ }} |
| 92 | +", |
| 93 | + }, |
| 94 | + FixedSources = |
| 95 | + { |
| 96 | + $@" |
| 97 | +using System; |
| 98 | +
|
| 99 | +namespace Namespace0; |
| 100 | +
|
| 101 | + [My] [My] {baseTypeKind} TypeName {{ }} |
| 102 | +", |
| 103 | + $@" |
| 104 | +using System; |
| 105 | +
|
| 106 | +namespace Namespace1; |
| 107 | +
|
| 108 | + [My] |
| 109 | + [My] {baseTypeKind} TypeName {{ }} |
| 110 | +", |
| 111 | + $@" |
| 112 | +using System; |
| 113 | +
|
| 114 | +namespace Namespace2; |
| 115 | +
|
| 116 | + [My] |
| 117 | + [My] |
| 118 | + {baseTypeKind} TypeName {{ }} |
| 119 | +", |
| 120 | + $@" |
| 121 | +using System; |
| 122 | +
|
| 123 | +namespace Namespace3; |
| 124 | +
|
| 125 | + [My] |
| 126 | + [My] |
| 127 | + {baseTypeKind} TypeName {{ }} |
| 128 | +", |
| 129 | + $@" |
| 130 | +using System; |
| 131 | +
|
| 132 | +namespace Namespace4; |
| 133 | +
|
| 134 | + {baseTypeKind} TypeName1 {{ }} |
| 135 | +
|
| 136 | + [My] {baseTypeKind} TypeName2 {{ }} |
| 137 | +", |
| 138 | + $@" |
| 139 | +using System; |
| 140 | +
|
| 141 | +namespace Namespace5; |
| 142 | +
|
| 143 | + {baseTypeKind} TypeName1 {{ }} |
| 144 | +
|
| 145 | + [My] |
| 146 | + [My] {baseTypeKind} TypeName2 {{ }} |
| 147 | +", |
| 148 | + $@" |
| 149 | +using System; |
| 150 | +
|
| 151 | +namespace Namespace6; |
| 152 | +
|
| 153 | + {baseTypeKind} TypeName1 {{ }} |
| 154 | +
|
| 155 | + [My] |
| 156 | + [My] {baseTypeKind} TypeName2 {{ }} |
| 157 | +", |
| 158 | + $@" |
| 159 | +using System; |
| 160 | +
|
| 161 | +[AttributeUsage(AttributeTargets.All, AllowMultiple = true)] |
| 162 | +class MyAttribute : Attribute {{ }} |
| 163 | +", |
| 164 | + }, |
| 165 | + }.RunAsync(CancellationToken.None).ConfigureAwait(false); |
| 166 | + } |
10 | 167 | } |
11 | 168 | } |
0 commit comments