44using System . Collections . Generic ;
55using System . Dynamic ;
66using System . Security . Claims ;
7+ using System . Threading . Tasks ;
78using Microsoft . AspNetCore . Http ;
89using Moq ;
910using NUnit . Framework ;
@@ -53,13 +54,13 @@ public void Initialize()
5354 }
5455
5556 [ Test ]
56- public void ProcessRequest_NoControllersMatchedNo404Controller_404Returned ( )
57+ public async Task ProcessControllers_NoControllersMatchedNo404Controller_404Returned ( )
5758 {
5859 // Assign
5960 _agent . Setup ( x => x . MatchControllerRoute ( It . IsAny < IControllerMetaData > ( ) , It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ) . Returns ( new RouteMatchResult ( ) ) ;
6061
6162 // Act
62- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
63+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
6364
6465 // Assert
6566
@@ -71,7 +72,7 @@ public void ProcessRequest_NoControllersMatchedNo404Controller_404Returned()
7172 }
7273
7374 [ Test ]
74- public void ProcessRequest_NoControllersMatchedButHave404Controller_404ControllerExecuted ( )
75+ public async Task ProcessControllers_NoControllersMatchedButHave404Controller_404ControllerExecuted ( )
7576 {
7677 // Assign
7778
@@ -81,7 +82,7 @@ public void ProcessRequest_NoControllersMatchedButHave404Controller_404Controlle
8182 . Returns ( new ControllerMetaData ( typeof ( TestController2 ) ) ) ;
8283
8384 // Act
84- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
85+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
8586
8687 // Assert
8788
@@ -96,7 +97,7 @@ public void ProcessRequest_NoControllersMatchedButHave404Controller_404Controlle
9697 }
9798
9899 [ Test ]
99- public void ProcessRequest_NoControllersMatchedButHave404ControllerRawResult_404ControllerExecutedRawReturned ( )
100+ public async Task ProcessControllers_NoControllersMatchedButHave404ControllerRawResult_404ControllerExecutedRawReturned ( )
100101 {
101102 // Assign
102103
@@ -108,10 +109,10 @@ public void ProcessRequest_NoControllersMatchedButHave404ControllerRawResult_404
108109 _controllersExecutor . Setup (
109110 x =>
110111 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
111- It . IsAny < HttpContext > ( ) , It . IsAny < IDictionary < string , Object > > ( ) ) ) . Returns ( ControllerResponseResult . RawOutput ) ;
112+ It . IsAny < HttpContext > ( ) , It . IsAny < IDictionary < string , Object > > ( ) ) ) . Returns ( Task . FromResult ( ControllerResponseResult . RawOutput ) ) ;
112113
113114 // Act
114- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
115+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
115116
116117 // Assert
117118
@@ -126,7 +127,7 @@ public void ProcessRequest_NoControllersMatchedButHave404ControllerRawResult_404
126127 }
127128
128129 [ Test ]
129- public void ProcessRequest_NoControllersMatchedButHave404ControllerRedirect_404ControllerExecutedRedirectReturned ( )
130+ public async Task ProcessControllers_NoControllersMatchedButHave404ControllerRedirect_404ControllerExecutedRedirectReturned ( )
130131 {
131132 // Assign
132133
@@ -138,10 +139,10 @@ public void ProcessRequest_NoControllersMatchedButHave404ControllerRedirect_404C
138139 _controllersExecutor . Setup (
139140 x =>
140141 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
141- It . IsAny < HttpContext > ( ) , It . IsAny < IDictionary < string , Object > > ( ) ) ) . Returns ( ControllerResponseResult . Redirect ) ;
142+ It . IsAny < HttpContext > ( ) , It . IsAny < IDictionary < string , Object > > ( ) ) ) . Returns ( Task . FromResult ( ControllerResponseResult . Redirect ) ) ;
142143
143144 // Act
144- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
145+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
145146
146147 // Assert
147148
@@ -156,7 +157,7 @@ public void ProcessRequest_NoControllersMatchedButHave404ControllerRedirect_404C
156157 }
157158
158159 [ Test ]
159- public void ProcessRequest_OnlyAnyPageControllerMatchedButHave404Controller_404ControllerExecuted ( )
160+ public async Task ProcessControllers_OnlyAnyPageControllerMatchedButHave404Controller_404ControllerExecuted ( )
160161 {
161162 // Assign
162163
@@ -167,7 +168,7 @@ public void ProcessRequest_OnlyAnyPageControllerMatchedButHave404Controller_404C
167168 _agent . Setup ( x => x . IsAnyPageController ( It . IsAny < IControllerMetaData > ( ) ) ) . Returns ( true ) ;
168169
169170 // Act
170- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
171+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
171172
172173 // Assert
173174
@@ -184,18 +185,20 @@ public void ProcessRequest_OnlyAnyPageControllerMatchedButHave404Controller_404C
184185 }
185186
186187 [ Test ]
187- public void ProcessRequest_StandardControllerMatched_Executed ( )
188+ public async Task ProcessControllers_StandardControllerMatched_Executed ( )
188189 {
189190 // Assign
190191 _agent . Setup ( x => x . IsAnyPageController ( It . IsAny < IControllerMetaData > ( ) ) ) . Returns ( false ) ;
191192
192193 // Act
193- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
194+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
194195
195196 // Assert
196197
197198 Assert . AreEqual ( ControllersProcessorResult . Ok , result ) ;
199+
198200 _agent . Verify ( x => x . IsAnyPageController ( It . IsAny < IControllerMetaData > ( ) ) ) ;
201+
199202 _controllersExecutor . Verify (
200203 x =>
201204 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController1 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
@@ -206,11 +209,12 @@ public void ProcessRequest_StandardControllerMatched_Executed()
206209 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
207210 It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == null ) ) , Times . Never ) ;
208211
209- _controllersExecutor . Verify ( x => x . ProcessAsyncControllersResponses ( It . IsAny < IDIContainerProvider > ( ) ) ) ;
212+ // Check
213+ //_controllersExecutor.Verify(x => x.ProcessAsyncControllersResponses(It.IsAny<IDIContainerProvider>()));
210214 }
211215
212216 [ Test ]
213- public void ProcessRequest_StandardControllersOneIsMatchedNull_ExecutedOnce ( )
217+ public async Task ProcessControllers_StandardControllersOneIsMatchedNull_ExecutedOnce ( )
214218 {
215219 // Assign
216220
@@ -226,7 +230,7 @@ public void ProcessRequest_StandardControllersOneIsMatchedNull_ExecutedOnce()
226230 } ) ;
227231
228232 // Act
229- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
233+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
230234
231235 // Assert
232236
@@ -242,11 +246,12 @@ public void ProcessRequest_StandardControllersOneIsMatchedNull_ExecutedOnce()
242246 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
243247 It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == null ) ) , Times . Never ) ;
244248
245- _controllersExecutor . Verify ( x => x . ProcessAsyncControllersResponses ( It . IsAny < IDIContainerProvider > ( ) ) , Times . Once ) ;
249+ // Check
250+ //_controllersExecutor.Verify(x => x.ProcessAsyncControllersResponses(It.IsAny<IDIContainerProvider>()), Times.Once);
246251 }
247252
248253 [ Test ]
249- public void ProcessRequest_StandardControllerMatchedReturnsRawData_ReturnedRawDataSubsequentNotExecuted ( )
254+ public async Task ProcessControllers_StandardControllerMatchedReturnsRawData_ReturnedRawDataSubsequentNotExecuted ( )
250255 {
251256 // Assign
252257
@@ -260,10 +265,11 @@ public void ProcessRequest_StandardControllerMatchedReturnsRawData_ReturnedRawDa
260265 _controllersExecutor . Setup (
261266 x =>
262267 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController1 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
263- It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == _routeParameters ) ) ) . Returns ( ControllerResponseResult . RawOutput ) ;
268+ It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == _routeParameters ) ) ) . Returns (
269+ Task . FromResult ( ControllerResponseResult . RawOutput ) ) ;
264270
265271 // Act
266- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
272+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
267273
268274 // Assert
269275
@@ -275,7 +281,7 @@ public void ProcessRequest_StandardControllerMatchedReturnsRawData_ReturnedRawDa
275281 }
276282
277283 [ Test ]
278- public void ProcessRequest_StandardControllerMatchedReturnsRedirect_ReturnedRedirectSubsequentNotExecuted ( )
284+ public async Task ProcessControllers_StandardControllerMatchedReturnsRedirect_ReturnedRedirectSubsequentNotExecuted ( )
279285 {
280286 // Assign
281287
@@ -289,10 +295,11 @@ public void ProcessRequest_StandardControllerMatchedReturnsRedirect_ReturnedRedi
289295 _controllersExecutor . Setup (
290296 x =>
291297 x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController1 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
292- It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == _routeParameters ) ) ) . Returns ( ControllerResponseResult . Redirect ) ;
298+ It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == _routeParameters ) ) ) . Returns (
299+ Task . FromResult ( ControllerResponseResult . Redirect ) ) ;
293300
294301 // Act
295- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
302+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
296303
297304 // Assert
298305
@@ -304,67 +311,13 @@ public void ProcessRequest_StandardControllerMatchedReturnsRedirect_ReturnedRedi
304311 }
305312
306313 [ Test ]
307- public void ProcessRequest_StandardAsyncControllerMatchedReturnsRawData_ReturnedRawDataSubsequentExecuted ( )
308- {
309- // Assign
310-
311- _agent . Setup ( x => x . IsAnyPageController ( It . IsAny < IControllerMetaData > ( ) ) ) . Returns ( false ) ;
312- _agent . Setup ( x => x . GetStandardControllersMetaData ( ) ) . Returns ( ( ) => new List < IControllerMetaData >
313- {
314- _metaData ,
315- _metaData
316- } ) ;
317-
318- _controllersExecutor . Setup ( x => x . ProcessAsyncControllersResponses ( It . IsAny < IDIContainerProvider > ( ) ) )
319- . Returns ( new List < ControllerResponseResult > { ControllerResponseResult . RawOutput } ) ;
320-
321- // Act
322- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
323-
324- // Assert
325-
326- Assert . AreEqual ( ControllersProcessorResult . RawOutput , result ) ;
327- _controllersExecutor . Verify (
328- x =>
329- x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController1 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
330- It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == _routeParameters ) ) , Times . Exactly ( 2 ) ) ;
331- }
332-
333- [ Test ]
334- public void ProcessRequest_StandardAsyncControllerMatchedReturnsRedirect_ReturnedRedirectSubsequentExecuted ( )
335- {
336- // Assign
337-
338- _agent . Setup ( x => x . IsAnyPageController ( It . IsAny < IControllerMetaData > ( ) ) ) . Returns ( false ) ;
339- _agent . Setup ( x => x . GetStandardControllersMetaData ( ) ) . Returns ( ( ) => new List < IControllerMetaData >
340- {
341- _metaData ,
342- _metaData
343- } ) ;
344-
345- _controllersExecutor . Setup ( x => x . ProcessAsyncControllersResponses ( It . IsAny < IDIContainerProvider > ( ) ) )
346- . Returns ( new List < ControllerResponseResult > { ControllerResponseResult . Redirect } ) ;
347-
348- // Act
349- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
350-
351- // Assert
352-
353- Assert . AreEqual ( ControllersProcessorResult . Redirect , result ) ;
354- _controllersExecutor . Verify (
355- x =>
356- x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController1 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
357- It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == _routeParameters ) ) , Times . Exactly ( 2 ) ) ;
358- }
359-
360- [ Test ]
361- public void ProcessRequest_NotAuthenticated_ReturnedHttp401 ( )
314+ public async Task ProcessControllers_NotAuthenticated_ReturnedHttp401 ( )
362315 {
363316 // Assign
364317 _agent . Setup ( x => x . IsSecurityRulesViolated ( It . IsAny < IControllerMetaData > ( ) , It . IsAny < ClaimsPrincipal > ( ) ) ) . Returns ( SecurityRuleCheckResult . NotAuthenticated ) ;
365318
366319 // Act
367- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
320+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
368321
369322 // Assert
370323
@@ -373,7 +326,7 @@ public void ProcessRequest_NotAuthenticated_ReturnedHttp401()
373326 }
374327
375328 [ Test ]
376- public void ProcessRequest_ForbiddenHave403Controller_403ControllerExecuted ( )
329+ public async Task ProcessControllers_ForbiddenHave403Controller_403ControllerExecuted ( )
377330 {
378331 // Assign
379332
@@ -383,7 +336,7 @@ public void ProcessRequest_ForbiddenHave403Controller_403ControllerExecuted()
383336 . Returns ( new ControllerMetaData ( typeof ( TestController2 ) ) ) ;
384337
385338 // Act
386- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
339+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
387340
388341 // Assert
389342
@@ -399,13 +352,13 @@ public void ProcessRequest_ForbiddenHave403Controller_403ControllerExecuted()
399352 }
400353
401354 [ Test ]
402- public void ProcessRequest_ForbiddenNotHave403Controller_Http403Returned ( )
355+ public async Task ProcessControllers_ForbiddenNotHave403Controller_Http403Returned ( )
403356 {
404357 // Assign
405358 _agent . Setup ( x => x . IsSecurityRulesViolated ( It . IsAny < IControllerMetaData > ( ) , It . IsAny < ClaimsPrincipal > ( ) ) ) . Returns ( SecurityRuleCheckResult . Forbidden ) ;
406359
407360 // Act
408- var result = _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
361+ var result = await _processor . ProcessControllers ( _containerProvider , _context . Object ) ;
409362
410363 // Assert
411364
0 commit comments