@@ -41,167 +41,173 @@ public void BuildPagedResult_NulLArg_BuildsPagedResult()
41
41
42
42
#region CatchClientSideEvaluationException
43
43
[ Fact ]
44
- public void CatchClientSideEvaluationException_NotCCEE_ThrowsOriginalException ( )
44
+ public async Task CatchClientSideEvaluationException_NotCCEE_ThrowsOriginalException ( )
45
45
{
46
46
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
47
47
ApplicationException exception = new ( "Original exception" ) ;
48
48
49
- static void evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
49
+ static Task evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
50
50
51
- Action act = ( ) => controller . CatchClientSideEvaluationException ( exception , "foo" , evaluator ) ;
52
- act . Should ( ) . Throw < ApplicationException > ( ) . WithMessage ( "Original exception" ) ;
51
+ Func < Task > act = async ( ) => await controller . CatchClientSideEvaluationExceptionAsync ( exception , "foo" , evaluator ) ;
52
+ ( await act . Should ( ) . ThrowAsync < ApplicationException > ( ) ) . WithMessage ( "Original exception" ) ;
53
53
}
54
54
55
55
[ Fact ]
56
- public void CatchClientSideEvaluationException_NotCCEE_WithInner_ThrowsOriginalException ( )
56
+ public async Task CatchClientSideEvaluationException_NotCCEE_WithInner_ThrowsOriginalException ( )
57
57
{
58
58
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
59
59
ApplicationException exception = new ( "Original exception" , new ApplicationException ( ) ) ;
60
60
61
- static void evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
61
+ static Task evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
62
62
63
- Action act = ( ) => controller . CatchClientSideEvaluationException ( exception , "foo" , evaluator ) ;
64
- act . Should ( ) . Throw < ApplicationException > ( ) . WithMessage ( "Original exception" ) ;
63
+ Func < Task > act = async ( ) => await controller . CatchClientSideEvaluationExceptionAsync ( exception , "foo" , evaluator ) ;
64
+ ( await act . Should ( ) . ThrowAsync < ApplicationException > ( ) ) . WithMessage ( "Original exception" ) ;
65
65
}
66
66
67
67
[ Fact ]
68
- public void CatchClientSideEvaluationException_CCEE_ThrowsEvaluatorException ( )
68
+ public async Task CatchClientSideEvaluationException_CCEE_ThrowsEvaluatorException ( )
69
69
{
70
70
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
71
71
NotSupportedException exception = new ( "Original exception" , new ApplicationException ( "foo" ) ) ;
72
72
73
- static void evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
73
+ static Task evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
74
74
75
- Action act = ( ) => controller . CatchClientSideEvaluationException ( exception , "foo" , evaluator ) ;
76
- act . Should ( ) . Throw < ApplicationException > ( ) . WithMessage ( "In evaluator" ) ;
75
+ Func < Task > act = async ( ) => await controller . CatchClientSideEvaluationExceptionAsync ( exception , "foo" , evaluator ) ;
76
+ ( await act . Should ( ) . ThrowAsync < ApplicationException > ( ) ) . WithMessage ( "In evaluator" ) ;
77
77
}
78
78
79
79
[ Fact ]
80
- public void CatchClientSideEvaluationException_CCEEInner_ThrowsEvaluatorException ( )
80
+ public async Task CatchClientSideEvaluationException_CCEEInner_ThrowsEvaluatorException ( )
81
81
{
82
82
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
83
83
ApplicationException exception = new ( "Original exception" , new NotSupportedException ( "foo" ) ) ;
84
84
85
- static void evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
85
+ static Task evaluator ( ) { throw new ApplicationException ( "In evaluator" ) ; }
86
86
87
- Action act = ( ) => controller . CatchClientSideEvaluationException ( exception , "foo" , evaluator ) ;
88
- act . Should ( ) . Throw < ApplicationException > ( ) . WithMessage ( "In evaluator" ) ;
87
+ Func < Task > act = async ( ) => await controller . CatchClientSideEvaluationExceptionAsync ( exception , "foo" , evaluator ) ;
88
+ ( await act . Should ( ) . ThrowAsync < ApplicationException > ( ) ) . WithMessage ( "In evaluator" ) ;
89
89
}
90
90
91
91
[ Fact ]
92
- public void CatchClientSideEvaluationException_CCEE_ExecutesEvaluator ( )
92
+ public async Task CatchClientSideEvaluationException_CCEE_ExecutesEvaluator ( )
93
93
{
94
94
bool isExecuted = false ;
95
95
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
96
96
NotSupportedException exception = new ( "Original exception" , new ApplicationException ( "foo" ) ) ;
97
- Action act = ( ) => controller . CatchClientSideEvaluationException ( exception , "foo" , ( ) => isExecuted = true ) ;
98
- act . Should ( ) . NotThrow ( ) ;
97
+
98
+ Func < Task > act = async ( ) => await controller . CatchClientSideEvaluationExceptionAsync ( exception , "foo" , ( ) => { isExecuted = true ; return Task . CompletedTask ; } ) ;
99
+ await act . Should ( ) . NotThrowAsync ( ) ;
99
100
isExecuted . Should ( ) . BeTrue ( ) ;
100
101
}
101
102
102
103
[ Fact ]
103
- public void CatchClientSideEvaluationException_CCEEInner_ExecutesEvaluator ( )
104
+ public async Task CatchClientSideEvaluationException_CCEEInner_ExecutesEvaluator ( )
104
105
{
105
106
bool isExecuted = false ;
106
107
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
107
108
ApplicationException exception = new ( "Original exception" , new NotSupportedException ( "foo" ) ) ;
108
- Action act = ( ) => controller . CatchClientSideEvaluationException ( exception , "foo" , ( ) => isExecuted = true ) ;
109
- act . Should ( ) . NotThrow ( ) ;
109
+
110
+ Func < Task > act = async ( ) => await controller . CatchClientSideEvaluationExceptionAsync ( exception , "foo" , ( ) => { isExecuted = true ; return Task . CompletedTask ; } ) ;
111
+ await act . Should ( ) . NotThrowAsync ( ) ;
110
112
isExecuted . Should ( ) . BeTrue ( ) ;
111
113
}
112
114
#endregion
113
115
114
116
#region ExecuteQueryWithClientEvaluation
115
117
[ Fact ]
116
- public void ExecuteQueryWithClientEvaluation_ExecutesServiceSide ( )
118
+ public async Task ExecuteQueryWithClientEvaluation_ExecutesServiceSide ( )
117
119
{
118
120
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
119
121
controller . Options . DisableClientSideEvaluation = true ;
120
122
121
123
int evaluations = 0 ;
122
- void evaluator ( IQueryable < InMemoryMovie > dataset )
124
+ Task evaluator ( IQueryable < InMemoryMovie > dataset )
123
125
{
124
126
evaluations ++ ;
125
127
// if (evaluations == 1) throw new NotSupportedException("Server side");
126
128
// if (evaluations == 2) throw new NotSupportedException("Client side");
129
+ return Task . CompletedTask ;
127
130
}
128
131
129
132
List < InMemoryMovie > dataset = [ ] ;
130
133
131
- Action act = ( ) => controller . ExecuteQueryWithClientEvaluation ( dataset . AsQueryable ( ) , evaluator ) ;
134
+ Func < Task > act = async ( ) => await controller . ExecuteQueryWithClientEvaluationAsync ( dataset . AsQueryable ( ) , evaluator ) ;
132
135
133
- act . Should ( ) . NotThrow ( ) ;
136
+ await act . Should ( ) . NotThrowAsync ( ) ;
134
137
evaluations . Should ( ) . Be ( 1 ) ;
135
138
}
136
139
137
140
[ Fact ]
138
- public void ExecuteQueryWithClientEvaluation_ThrowsServiceSide_WhenClientEvaluationDisabled ( )
141
+ public async Task ExecuteQueryWithClientEvaluation_ThrowsServiceSide_WhenClientEvaluationDisabled ( )
139
142
{
140
143
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
141
144
controller . Options . DisableClientSideEvaluation = true ;
142
145
143
146
int evaluations = 0 ;
144
147
#pragma warning disable IDE0011 // Add braces
145
- void evaluator ( IQueryable < InMemoryMovie > dataset )
148
+ Task evaluator ( IQueryable < InMemoryMovie > dataset )
146
149
{
147
150
evaluations ++ ;
148
151
if ( evaluations == 1 ) throw new NotSupportedException ( "Server side" ) ;
149
152
if ( evaluations == 2 ) throw new NotSupportedException ( "Client side" ) ;
153
+ return Task . CompletedTask ;
150
154
}
151
155
#pragma warning restore IDE0011 // Add braces
152
156
153
157
List < InMemoryMovie > dataset = [ ] ;
154
158
155
- Action act = ( ) => controller . ExecuteQueryWithClientEvaluation ( dataset . AsQueryable ( ) , evaluator ) ;
159
+ Func < Task > act = async ( ) => await controller . ExecuteQueryWithClientEvaluationAsync ( dataset . AsQueryable ( ) , evaluator ) ;
156
160
157
- act . Should ( ) . Throw < NotSupportedException > ( ) . WithMessage ( "Server side" ) ;
161
+ ( await act . Should ( ) . ThrowAsync < NotSupportedException > ( ) ) . WithMessage ( "Server side" ) ;
158
162
}
159
163
160
164
[ Fact ]
161
- public void ExecuteQueryWithClientEvaluation_ExecutesClientSide_WhenClientEvaluationEnabled ( )
165
+ public async Task ExecuteQueryWithClientEvaluation_ExecutesClientSide_WhenClientEvaluationEnabled ( )
162
166
{
163
167
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
164
168
controller . Options . DisableClientSideEvaluation = false ;
165
169
166
170
int evaluations = 0 ;
167
171
#pragma warning disable IDE0011 // Add braces
168
- void evaluator ( IQueryable < InMemoryMovie > dataset )
172
+ Task evaluator ( IQueryable < InMemoryMovie > dataset )
169
173
{
170
174
evaluations ++ ;
171
175
if ( evaluations == 1 ) throw new NotSupportedException ( "Server side" ) ;
172
176
//if (evaluations == 2) throw new NotSupportedException("Client side");
177
+ return Task . CompletedTask ;
173
178
}
174
179
#pragma warning restore IDE0011 // Add braces
175
180
176
181
List < InMemoryMovie > dataset = [ ] ;
177
182
178
- Action act = ( ) => controller . ExecuteQueryWithClientEvaluation ( dataset . AsQueryable ( ) , evaluator ) ;
183
+ Func < Task > act = async ( ) => await controller . ExecuteQueryWithClientEvaluationAsync ( dataset . AsQueryable ( ) , evaluator ) ;
179
184
180
- act . Should ( ) . NotThrow ( ) ;
185
+ await act . Should ( ) . NotThrowAsync ( ) ;
181
186
evaluations . Should ( ) . Be ( 2 ) ;
182
187
}
183
188
184
189
[ Fact ]
185
- public void ExecuteQueryWithClientEvaluation_ThrowsClientSide_WhenClientEvaluationEnabled ( )
190
+ public async Task ExecuteQueryWithClientEvaluation_ThrowsClientSide_WhenClientEvaluationEnabled ( )
186
191
{
187
192
TableController < InMemoryMovie > controller = new ( ) { Repository = new InMemoryRepository < InMemoryMovie > ( ) } ;
188
193
controller . Options . DisableClientSideEvaluation = false ;
189
194
190
195
int evaluations = 0 ;
191
196
#pragma warning disable IDE0011 // Add braces
192
- void evaluator ( IQueryable < InMemoryMovie > dataset )
197
+ Task evaluator ( IQueryable < InMemoryMovie > dataset )
193
198
{
194
199
evaluations ++ ;
195
200
if ( evaluations == 1 ) throw new NotSupportedException ( "Server side" , new ApplicationException ( "Inner exception" ) ) ;
196
201
if ( evaluations == 2 ) throw new NotSupportedException ( "Client side" ) ;
202
+ return Task . CompletedTask ;
197
203
}
198
204
#pragma warning restore IDE0011 // Add braces
199
205
200
206
List < InMemoryMovie > dataset = [ ] ;
201
207
202
- Action act = ( ) => controller . ExecuteQueryWithClientEvaluation ( dataset . AsQueryable ( ) , evaluator ) ;
208
+ Func < Task > act = async ( ) => await controller . ExecuteQueryWithClientEvaluationAsync ( dataset . AsQueryable ( ) , evaluator ) ;
203
209
204
- act . Should ( ) . Throw < NotSupportedException > ( ) . WithMessage ( "Client side" ) ;
210
+ ( await act . Should ( ) . ThrowAsync < NotSupportedException > ( ) ) . WithMessage ( "Client side" ) ;
205
211
evaluations . Should ( ) . Be ( 2 ) ;
206
212
}
207
213
#endregion
0 commit comments