|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules |
5 | 5 | { |
| 6 | + using System.Threading; |
| 7 | + using System.Threading.Tasks; |
| 8 | + using Microsoft.CodeAnalysis; |
6 | 9 | using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; |
| 10 | + using StyleCop.Analyzers.Test.Verifiers; |
| 11 | + using Xunit; |
| 12 | + using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier<StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName>; |
7 | 13 |
|
8 | 14 | public partial class SA1649CSharp9UnitTests : SA1649CSharp8UnitTests |
9 | 15 | { |
| 16 | + [Fact] |
| 17 | + [WorkItem(3967, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3967")] |
| 18 | + public async Task VerifyTopLevelStatementsOnlyDoNotReportAsync() |
| 19 | + { |
| 20 | + var testCode = @"System.Console.WriteLine(); |
| 21 | +"; |
| 22 | + |
| 23 | + var test = new StyleCopCodeFixVerifier<StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName, StyleCop.Analyzers.DocumentationRules.SA1649CodeFixProvider>.CSharpTest() |
| 24 | + { |
| 25 | + TestState = |
| 26 | + { |
| 27 | + OutputKind = OutputKind.ConsoleApplication, |
| 28 | + Sources = { ("Program.cs", testCode) }, |
| 29 | + }, |
| 30 | + }; |
| 31 | + |
| 32 | + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); |
| 33 | + } |
| 34 | + |
| 35 | + [Fact] |
| 36 | + [WorkItem(3967, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3967")] |
| 37 | + public async Task VerifyTopLevelStatementsFollowedByClassReportAsync() |
| 38 | + { |
| 39 | + var testCode = @"System.Console.WriteLine(); |
| 40 | +
|
| 41 | +class {|#0:Helper|} |
| 42 | +{ |
| 43 | +} |
| 44 | +"; |
| 45 | + |
| 46 | + var fixedCode = @"System.Console.WriteLine(); |
| 47 | +
|
| 48 | +class Helper |
| 49 | +{ |
| 50 | +} |
| 51 | +"; |
| 52 | + |
| 53 | + var test = new StyleCopCodeFixVerifier<StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName, StyleCop.Analyzers.DocumentationRules.SA1649CodeFixProvider>.CSharpTest() |
| 54 | + { |
| 55 | + TestState = |
| 56 | + { |
| 57 | + OutputKind = OutputKind.ConsoleApplication, |
| 58 | + Sources = { ("Program.cs", testCode) }, |
| 59 | + }, |
| 60 | + FixedSources = { ("Helper.cs", fixedCode) }, |
| 61 | + }; |
| 62 | + |
| 63 | + test.TestState.ExpectedDiagnostics.Add(Diagnostic().WithLocation(0)); |
| 64 | + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); |
| 65 | + } |
| 66 | + |
| 67 | + [Fact] |
| 68 | + [WorkItem(3967, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3967")] |
| 69 | + public async Task VerifyTopLevelStatementsFollowedByEnumReportAsync() |
| 70 | + { |
| 71 | + var testCode = @"System.Console.WriteLine(); |
| 72 | +
|
| 73 | +enum {|#0:Helper|} |
| 74 | +{ |
| 75 | + Value, |
| 76 | +} |
| 77 | +"; |
| 78 | + |
| 79 | + var fixedCode = @"System.Console.WriteLine(); |
| 80 | +
|
| 81 | +enum Helper |
| 82 | +{ |
| 83 | + Value, |
| 84 | +} |
| 85 | +"; |
| 86 | + |
| 87 | + var test = new StyleCopCodeFixVerifier<StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName, StyleCop.Analyzers.DocumentationRules.SA1649CodeFixProvider>.CSharpTest() |
| 88 | + { |
| 89 | + TestState = |
| 90 | + { |
| 91 | + OutputKind = OutputKind.ConsoleApplication, |
| 92 | + Sources = { ("Program.cs", testCode) }, |
| 93 | + }, |
| 94 | + FixedSources = { ("Helper.cs", fixedCode) }, |
| 95 | + }; |
| 96 | + |
| 97 | + test.TestState.ExpectedDiagnostics.Add(Diagnostic().WithLocation(0)); |
| 98 | + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); |
| 99 | + } |
10 | 100 | } |
11 | 101 | } |
0 commit comments