11// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
4- #nullable disable
5-
64namespace StyleCop . Analyzers . Test . ReadabilityRules
75{
86 using System . Threading ;
97 using System . Threading . Tasks ;
108 using Microsoft . CodeAnalysis . Testing ;
119 using StyleCop . Analyzers . ReadabilityRules ;
10+ using StyleCop . Analyzers . Test . Helpers ;
1211 using Xunit ;
1312 using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
1413 StyleCop . Analyzers . ReadabilityRules . SA1136EnumValuesShouldBeOnSeparateLines ,
@@ -23,16 +22,19 @@ public class SA1136UnitTests
2322 /// Verifies that an enum declaration with all values on the same line will return the expected diagnostics.
2423 /// This also verifies that an enum declaration with all values on separate lines will not produce diagnostics.
2524 /// </summary>
25+ /// <param name="lineEnding">The line ending to use in the test code.</param>
2626 /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
27- [ Fact ]
28- public async Task TestSingleLineEnumDeclarationAsync ( )
27+ [ Theory ]
28+ [ InlineData ( "\n " ) ]
29+ [ InlineData ( "\r \n " ) ]
30+ public async Task TestSingleLineEnumDeclarationAsync ( string lineEnding )
2931 {
3032 var testCode = @"
3133public enum TestEnum
3234{
33- FirstValue, SecondValue, ThirdValue
35+ FirstValue, {|#0: SecondValue|}, {|#1: ThirdValue|}
3436}
35- " ;
37+ " . ReplaceLineEndings ( lineEnding ) ;
3638
3739 var fixedTestCode = @"
3840public enum TestEnum
@@ -41,12 +43,12 @@ public enum TestEnum
4143 SecondValue,
4244 ThirdValue
4345}
44- " ;
46+ " . ReplaceLineEndings ( lineEnding ) ;
4547
4648 DiagnosticResult [ ] expected =
4749 {
48- Diagnostic ( ) . WithLocation ( 4 , 17 ) ,
49- Diagnostic ( ) . WithLocation ( 4 , 30 ) ,
50+ Diagnostic ( ) . WithLocation ( 0 ) ,
51+ Diagnostic ( ) . WithLocation ( 1 ) ,
5052 } ;
5153
5254 await VerifyCSharpFixAsync ( testCode , expected , fixedTestCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
0 commit comments