@@ -14,8 +14,10 @@ namespace AsyncUsageAnalyzers.Test.Usage
1414
1515 public class UseConfigureAwaitUnitTests : CodeFixVerifier
1616 {
17- [ Fact ]
18- public async Task TestSimpleExpressionAsync ( )
17+ [ Theory ]
18+ [ InlineData ( 0 , "false" ) ]
19+ [ InlineData ( 1 , "true" ) ]
20+ public async Task TestSimpleExpressionAsync ( int codeFixIndex , string configureAwaitArgument )
1921 {
2022 string testCode = @"
2123using System.Threading.Tasks;
@@ -27,21 +29,21 @@ async Task MethodNameAsync()
2729 }
2830}
2931" ;
30- string fixedCode = @"
32+ string fixedCode = $ @ "
3133using System.Threading.Tasks;
3234class ClassName
33- {
35+ {{
3436 async Task MethodNameAsync()
35- {
36- await Task.Delay(1000).ConfigureAwait(false );
37- }
38- }
37+ {{
38+ await Task.Delay(1000).ConfigureAwait({ configureAwaitArgument } );
39+ }}
40+ }}
3941" ;
4042
4143 DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 7 , 15 ) ;
4244 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
4345 await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
44- await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
46+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , codeFixIndex : codeFixIndex , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
4547 }
4648
4749 [ Fact ]
@@ -61,8 +63,10 @@ async Task MethodNameAsync()
6163 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
6264 }
6365
64- [ Fact ]
65- public async Task TestNestedExpressionsAsync ( )
66+ [ Theory ]
67+ [ InlineData ( 0 , "false" ) ]
68+ [ InlineData ( 1 , "true" ) ]
69+ public async Task TestNestedExpressionsAsync ( int codeFixIndex , string configureAwaitArgument )
6670 {
6771 string testCode = @"
6872using System.Threading.Tasks;
@@ -79,20 +83,20 @@ async Task MethodNameAsync()
7983 }
8084}
8185" ;
82- string fixedCode = @"
86+ string fixedCode = $ @ "
8387using System.Threading.Tasks;
8488class ClassName
85- {
89+ {{
8690 async Task<Task> FirstMethodAsync()
87- {
91+ {{
8892 return Task.FromResult(true);
89- }
93+ }}
9094
9195 async Task MethodNameAsync()
92- {
93- await (await FirstMethodAsync().ConfigureAwait(false )).ConfigureAwait(false );
94- }
95- }
96+ {{
97+ await (await FirstMethodAsync().ConfigureAwait({ configureAwaitArgument } )).ConfigureAwait({ configureAwaitArgument } );
98+ }}
99+ }}
96100" ;
97101
98102 DiagnosticResult [ ] expected =
@@ -102,7 +106,7 @@ async Task MethodNameAsync()
102106 } ;
103107 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
104108 await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
105- await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
109+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , codeFixIndex : codeFixIndex , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
106110 }
107111
108112 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
0 commit comments