12
12
using Simplify . Web . Core . Controllers ;
13
13
using Simplify . Web . Core . Controllers . Execution ;
14
14
using Simplify . Web . Meta ;
15
+ using Simplify . Web . Modules ;
15
16
using Simplify . Web . Routing ;
16
17
using Simplify . Web . Tests . TestEntities ;
17
18
@@ -25,6 +26,7 @@ public class ControllersProcessorTests
25
26
private ControllersProcessor _processor ;
26
27
private Mock < IControllersAgent > _agent ;
27
28
private Mock < IControllerExecutor > _controllersExecutor ;
29
+ private Mock < IRedirector > _redirector ;
28
30
private Mock < HttpContext > _context ;
29
31
30
32
private ControllerMetaData _metaData ;
@@ -34,7 +36,8 @@ public void Initialize()
34
36
{
35
37
_agent = new Mock < IControllersAgent > ( ) ;
36
38
_controllersExecutor = new Mock < IControllerExecutor > ( ) ;
37
- _processor = new ControllersProcessor ( _agent . Object , _controllersExecutor . Object ) ;
39
+ _redirector = new Mock < IRedirector > ( ) ;
40
+ _processor = new ControllersProcessor ( _agent . Object , _controllersExecutor . Object , _redirector . Object ) ;
38
41
39
42
_context = new Mock < HttpContext > ( ) ;
40
43
@@ -49,6 +52,10 @@ public void Initialize()
49
52
50
53
_agent . Setup ( x => x . IsSecurityRulesViolated ( It . IsAny < IControllerMetaData > ( ) , It . IsAny < ClaimsPrincipal > ( ) ) ) . Returns ( SecurityRuleCheckResult . Ok ) ;
51
54
55
+ // Setup current URL
56
+
57
+ _context . SetupGet ( x => x . Request . Scheme ) . Returns ( "http" ) ;
58
+ _context . SetupGet ( x => x . Request . Host ) . Returns ( new HostString ( "localhost" , 8080 ) ) ;
52
59
_context . SetupGet ( x => x . Request . Path ) . Returns ( new PathString ( "/foo/bar" ) ) ;
53
60
_context . SetupGet ( x => x . Request . Method ) . Returns ( "GET" ) ;
54
61
}
@@ -94,6 +101,8 @@ public async Task ProcessControllers_NoControllersMatchedButHave404Controller_40
94
101
_controllersExecutor . Verify ( x =>
95
102
x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
96
103
It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == null ) ) ) ;
104
+
105
+ _redirector . VerifySet ( x => x . PreviousPageUrl = It . IsAny < string > ( ) , Times . Never ) ;
97
106
}
98
107
99
108
[ Test ]
@@ -209,6 +218,8 @@ public async Task ProcessControllers_StandardControllerMatched_Executed()
209
218
x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
210
219
It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == null ) ) , Times . Never ) ;
211
220
221
+ _redirector . Verify ( x => x . SetPreviousPageUrlToCurrentPage ( ) ) ;
222
+
212
223
// Check
213
224
//_controllersExecutor.Verify(x => x.ProcessAsyncControllersResponses(It.IsAny<IDIContainerProvider>()));
214
225
}
@@ -349,6 +360,8 @@ public async Task ProcessControllers_ForbiddenHave403Controller_403ControllerExe
349
360
x . Execute ( It . Is < IControllerMetaData > ( t => t . ControllerType == typeof ( TestController2 ) ) , It . IsAny < IDIContainerProvider > ( ) ,
350
361
It . IsAny < HttpContext > ( ) , It . Is < IDictionary < string , Object > > ( d => d == null ) ) ) ;
351
362
_agent . Setup ( x => x . IsSecurityRulesViolated ( It . IsAny < IControllerMetaData > ( ) , It . IsAny < ClaimsPrincipal > ( ) ) ) ;
363
+
364
+ _redirector . VerifySet ( x => x . PreviousPageUrl = It . IsAny < string > ( ) , Times . Never ) ;
352
365
}
353
366
354
367
[ Test ]
0 commit comments