@@ -14,8 +14,10 @@ namespace AsyncUsageAnalyzers.Test.Usage
14
14
15
15
public class UseConfigureAwaitUnitTests : CodeFixVerifier
16
16
{
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 )
19
21
{
20
22
string testCode = @"
21
23
using System.Threading.Tasks;
@@ -27,21 +29,21 @@ async Task MethodNameAsync()
27
29
}
28
30
}
29
31
" ;
30
- string fixedCode = @"
32
+ string fixedCode = $ @ "
31
33
using System.Threading.Tasks;
32
34
class ClassName
33
- {
35
+ {{
34
36
async Task MethodNameAsync()
35
- {
36
- await Task.Delay(1000).ConfigureAwait(false );
37
- }
38
- }
37
+ {{
38
+ await Task.Delay(1000).ConfigureAwait({ configureAwaitArgument } );
39
+ }}
40
+ }}
39
41
" ;
40
42
41
43
DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 7 , 15 ) ;
42
44
await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
43
45
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 ) ;
45
47
}
46
48
47
49
[ Fact ]
@@ -61,8 +63,10 @@ async Task MethodNameAsync()
61
63
await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
62
64
}
63
65
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 )
66
70
{
67
71
string testCode = @"
68
72
using System.Threading.Tasks;
@@ -79,20 +83,20 @@ async Task MethodNameAsync()
79
83
}
80
84
}
81
85
" ;
82
- string fixedCode = @"
86
+ string fixedCode = $ @ "
83
87
using System.Threading.Tasks;
84
88
class ClassName
85
- {
89
+ {{
86
90
async Task<Task> FirstMethodAsync()
87
- {
91
+ {{
88
92
return Task.FromResult(true);
89
- }
93
+ }}
90
94
91
95
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
+ }}
96
100
" ;
97
101
98
102
DiagnosticResult [ ] expected =
@@ -102,7 +106,7 @@ async Task MethodNameAsync()
102
106
} ;
103
107
await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
104
108
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 ) ;
106
110
}
107
111
108
112
protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
0 commit comments