|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules
|
5 | 5 | {
|
| 6 | + using System; |
| 7 | + using System.Threading; |
| 8 | + using System.Threading.Tasks; |
| 9 | + using Microsoft.CodeAnalysis.Testing; |
6 | 10 | using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules;
|
| 11 | + using Xunit; |
7 | 12 |
|
8 | 13 | public partial class SA1402ForClassCSharp11UnitTests : SA1402ForClassCSharp10UnitTests
|
9 | 14 | {
|
| 15 | + /// <summary> |
| 16 | + /// Verifies that SA1402 is not reported for file-local class types. |
| 17 | + /// </summary> |
| 18 | + /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns> |
| 19 | + [Fact] |
| 20 | + [WorkItem(3803, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3803")] |
| 21 | + public async Task VerifyFileLocalClassExemptionAsync() |
| 22 | + { |
| 23 | + var testCode = $@"namespace TestNamespace; |
| 24 | +
|
| 25 | +public class TestClass1 {{ }} |
| 26 | +
|
| 27 | +file class TestClass2 {{ }} |
| 28 | +"; |
| 29 | + |
| 30 | + var expectedDiagnostic = this.Diagnostic().WithLocation(0); |
| 31 | + |
| 32 | + await this.VerifyCSharpDiagnosticAsync( |
| 33 | + testCode, |
| 34 | + this.GetSettings(), |
| 35 | + Array.Empty<DiagnosticResult>(), |
| 36 | + CancellationToken.None).ConfigureAwait(false); |
| 37 | + } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Verifies that SA1402 is not reported for file-local static class types. |
| 41 | + /// </summary> |
| 42 | + /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns> |
| 43 | + [Fact] |
| 44 | + [WorkItem(3803, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3803")] |
| 45 | + public async Task VerifyFileLocalStaticClassExemptionAsync() |
| 46 | + { |
| 47 | + var testCode = $@"namespace TestNamespace; |
| 48 | +
|
| 49 | +public class TestClass1 {{ }} |
| 50 | +
|
| 51 | +file static class TestClass2 {{ }} |
| 52 | +"; |
| 53 | + |
| 54 | + var expectedDiagnostic = this.Diagnostic().WithLocation(0); |
| 55 | + |
| 56 | + await this.VerifyCSharpDiagnosticAsync( |
| 57 | + testCode, |
| 58 | + this.GetSettings(), |
| 59 | + Array.Empty<DiagnosticResult>(), |
| 60 | + CancellationToken.None).ConfigureAwait(false); |
| 61 | + } |
10 | 62 | }
|
11 | 63 | }
|
0 commit comments