|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules |
5 | 5 | { |
| 6 | + using System.Threading.Tasks; |
| 7 | + using Microsoft.CodeAnalysis; |
| 8 | + using Microsoft.CodeAnalysis.CSharp; |
6 | 9 | using StyleCop.Analyzers.Test.DocumentationRules; |
| 10 | + using Xunit; |
7 | 11 |
|
8 | 12 | public class SA1600CSharp7UnitTests : SA1600UnitTests |
9 | 13 | { |
| 14 | + private string currentTestSettings; |
| 15 | + |
| 16 | + [Fact] |
| 17 | + public async Task TestPrivateProtectedDelegateWithoutDocumentationAsync() |
| 18 | + { |
| 19 | + await this.TestNestedDelegateDeclarationDocumentationAsync("private protected", true, false).ConfigureAwait(false); |
| 20 | + } |
| 21 | + |
| 22 | + [Fact] |
| 23 | + public async Task TestPrivateProtectedDelegateWithDocumentationAsync() |
| 24 | + { |
| 25 | + await this.TestNestedDelegateDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 26 | + } |
| 27 | + |
| 28 | + [Fact] |
| 29 | + public async Task TestPrivateProtectedMethodWithoutDocumentationAsync() |
| 30 | + { |
| 31 | + await this.TestMethodDeclarationDocumentationAsync("private protected", false, true, false).ConfigureAwait(false); |
| 32 | + } |
| 33 | + |
| 34 | + [Fact] |
| 35 | + public async Task TestPrivateProtectedMethodWithDocumentationAsync() |
| 36 | + { |
| 37 | + await this.TestMethodDeclarationDocumentationAsync("private protected", false, false, true).ConfigureAwait(false); |
| 38 | + } |
| 39 | + |
| 40 | + [Fact] |
| 41 | + public async Task TestPrivateProtectedConstructorWithoutDocumentationAsync() |
| 42 | + { |
| 43 | + await this.TestConstructorDeclarationDocumentationAsync("private protected", true, false).ConfigureAwait(false); |
| 44 | + } |
| 45 | + |
| 46 | + [Fact] |
| 47 | + public async Task TestPrivateProtectedConstructorWithDocumentationAsync() |
| 48 | + { |
| 49 | + await this.TestConstructorDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 50 | + } |
| 51 | + |
| 52 | + [Fact] |
| 53 | + public async Task TestPrivateProtectedFieldWithoutDocumentationAsync() |
| 54 | + { |
| 55 | + await this.TestFieldDeclarationDocumentationAsync("private protected", true, false).ConfigureAwait(false); |
| 56 | + |
| 57 | + // Re-test with the 'documentPrivateElements' setting enabled (doesn't impact fields) |
| 58 | + this.currentTestSettings = @" |
| 59 | +{ |
| 60 | + ""settings"": { |
| 61 | + ""documentationRules"": { |
| 62 | + ""documentPrivateElements"": true |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | +"; |
| 67 | + |
| 68 | + await this.TestFieldDeclarationDocumentationAsync("private protected", true, false).ConfigureAwait(false); |
| 69 | + |
| 70 | + // Re-test with the 'documentInternalElements' setting disabled (does impact fields) |
| 71 | + this.currentTestSettings = @" |
| 72 | +{ |
| 73 | + ""settings"": { |
| 74 | + ""documentationRules"": { |
| 75 | + ""documentInternalElements"": false |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +"; |
| 80 | + |
| 81 | + await this.TestFieldDeclarationDocumentationAsync("private protected", false, false).ConfigureAwait(false); |
| 82 | + |
| 83 | + // Re-test with the 'documentPrivateFields' setting enabled (does impact fields) |
| 84 | + this.currentTestSettings = @" |
| 85 | +{ |
| 86 | + ""settings"": { |
| 87 | + ""documentationRules"": { |
| 88 | + ""documentPrivateFields"": true |
| 89 | + } |
| 90 | + } |
| 91 | +} |
| 92 | +"; |
| 93 | + |
| 94 | + await this.TestFieldDeclarationDocumentationAsync("private protected", true, false).ConfigureAwait(false); |
| 95 | + } |
| 96 | + |
| 97 | + [Fact] |
| 98 | + public async Task TestPrivateProtectedFieldWithDocumentationAsync() |
| 99 | + { |
| 100 | + await this.TestFieldDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 101 | + |
| 102 | + // Re-test with the 'documentPrivateElements' setting enabled (doesn't impact fields) |
| 103 | + this.currentTestSettings = @" |
| 104 | +{ |
| 105 | + ""settings"": { |
| 106 | + ""documentationRules"": { |
| 107 | + ""documentPrivateElements"": true |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | +"; |
| 112 | + |
| 113 | + await this.TestFieldDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 114 | + |
| 115 | + // Re-test with the 'documentInternalElements' setting disabled (does impact fields) |
| 116 | + this.currentTestSettings = @" |
| 117 | +{ |
| 118 | + ""settings"": { |
| 119 | + ""documentationRules"": { |
| 120 | + ""documentInternalElements"": false |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | +"; |
| 125 | + |
| 126 | + await this.TestFieldDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 127 | + |
| 128 | + // Re-test with the 'documentPrivateFields' setting enabled (does impact fields) |
| 129 | + this.currentTestSettings = @" |
| 130 | +{ |
| 131 | + ""settings"": { |
| 132 | + ""documentationRules"": { |
| 133 | + ""documentPrivateFields"": true |
| 134 | + } |
| 135 | + } |
| 136 | +} |
| 137 | +"; |
| 138 | + |
| 139 | + await this.TestFieldDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 140 | + } |
| 141 | + |
| 142 | + [Fact] |
| 143 | + public async Task TestPrivateProtectedPropertyWithoutDocumentationAsync() |
| 144 | + { |
| 145 | + await this.TestPropertyDeclarationDocumentationAsync("private protected", false, true, false).ConfigureAwait(false); |
| 146 | + } |
| 147 | + |
| 148 | + [Fact] |
| 149 | + public async Task TestPrivateProtectedPropertyWithDocumentationAsync() |
| 150 | + { |
| 151 | + await this.TestPropertyDeclarationDocumentationAsync("private protected", false, false, true).ConfigureAwait(false); |
| 152 | + } |
| 153 | + |
| 154 | + [Fact] |
| 155 | + public async Task TestPrivateProtectedIndexerWithoutDocumentationAsync() |
| 156 | + { |
| 157 | + await this.TestIndexerDeclarationDocumentationAsync("private protected", false, true, false).ConfigureAwait(false); |
| 158 | + } |
| 159 | + |
| 160 | + [Fact] |
| 161 | + public async Task TestPrivateProtectedIndexerWithDocumentationAsync() |
| 162 | + { |
| 163 | + await this.TestIndexerDeclarationDocumentationAsync("private protected", false, false, true).ConfigureAwait(false); |
| 164 | + } |
| 165 | + |
| 166 | + [Fact] |
| 167 | + public async Task TestPrivateProtectedEventWithoutDocumentationAsync() |
| 168 | + { |
| 169 | + await this.TestEventDeclarationDocumentationAsync("private protected", false, true, false).ConfigureAwait(false); |
| 170 | + } |
| 171 | + |
| 172 | + [Fact] |
| 173 | + public async Task TestPrivateProtectedEventWithDocumentationAsync() |
| 174 | + { |
| 175 | + await this.TestEventDeclarationDocumentationAsync("private protected", false, false, true).ConfigureAwait(false); |
| 176 | + } |
| 177 | + |
| 178 | + [Fact] |
| 179 | + public async Task TestPrivateProtectedEventFieldWithoutDocumentationAsync() |
| 180 | + { |
| 181 | + await this.TestEventFieldDeclarationDocumentationAsync("private protected", true, false).ConfigureAwait(false); |
| 182 | + } |
| 183 | + |
| 184 | + [Fact] |
| 185 | + public async Task TestPrivateProtectedEventFieldWithDocumentationAsync() |
| 186 | + { |
| 187 | + await this.TestEventFieldDeclarationDocumentationAsync("private protected", false, true).ConfigureAwait(false); |
| 188 | + } |
| 189 | + |
| 190 | + protected override string GetSettings() |
| 191 | + { |
| 192 | + return this.currentTestSettings ?? base.GetSettings(); |
| 193 | + } |
| 194 | + |
| 195 | + protected override Project CreateProjectImpl(string[] sources, string language, string[] filenames) |
| 196 | + { |
| 197 | + var project = base.CreateProjectImpl(sources, language, filenames); |
| 198 | + var parseOptions = (CSharpParseOptions)project.ParseOptions; |
| 199 | + return project.WithParseOptions(parseOptions.WithLanguageVersion(LanguageVersion.CSharp7_2)); |
| 200 | + } |
| 201 | + |
| 202 | + protected override async Task TestTypeWithoutDocumentationAsync(string type, bool isInterface) |
| 203 | + { |
| 204 | + await base.TestTypeWithoutDocumentationAsync(type, isInterface).ConfigureAwait(false); |
| 205 | + |
| 206 | + await this.TestNestedTypeDeclarationDocumentationAsync(type, "private protected", true, false).ConfigureAwait(false); |
| 207 | + } |
| 208 | + |
| 209 | + protected override async Task TestTypeWithDocumentationAsync(string type) |
| 210 | + { |
| 211 | + await base.TestTypeWithDocumentationAsync(type).ConfigureAwait(false); |
| 212 | + |
| 213 | + await this.TestNestedTypeDeclarationDocumentationAsync(type, "private protected", false, true).ConfigureAwait(false); |
| 214 | + } |
10 | 215 | } |
11 | 216 | } |
0 commit comments