File tree Expand file tree Collapse file tree
MyTested.AspNetCore.Mvc.Abstractions/Internal/TestContexts
MyTested.AspNetCore.Mvc.Pipeline
MyTested.AspNetCore.Mvc.Routing Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212 public abstract class HttpTestContext
1313 {
14- private HttpContextMock httpContextMock ;
1514 private RouteData routeData ;
1615
1716 protected HttpTestContext ( )
1817 {
1918 TestHelper . ExecuteTestCleanup ( ) ;
20- this . httpContextMock = TestHelper . CreateHttpContextMock ( ) ;
19+ this . HttpContextMock = TestHelper . CreateHttpContextMock ( ) ;
2120 }
2221
2322 public HttpContext HttpContext
2423 {
25- get => this . httpContextMock ;
24+ get => this . HttpContextMock ;
2625
2726 set
2827 {
2928 CommonValidator . CheckForNullReference ( value , nameof ( this . HttpContext ) ) ;
30- this . httpContextMock = HttpContextMock . From ( value ) ;
31- TestHelper . SetHttpContextToAccessor ( this . httpContextMock ) ;
29+ this . HttpContextMock = HttpContextMock . From ( value ) ;
30+ TestHelper . SetHttpContextToAccessor ( this . HttpContextMock ) ;
3231 }
3332 }
3433
34+ public HttpContextMock HttpContextMock { get ; private set ; }
35+
3536 public HttpRequest HttpRequest => this . HttpContext . Request ;
3637
3738 public HttpResponse HttpResponse => this . HttpContext . Response ;
@@ -64,7 +65,5 @@ public virtual RouteData RouteData
6465 public ISession Session => this . HttpContext . Session ;
6566
6667 public abstract string ExceptionMessagePrefix { get ; }
67-
68- public HttpContextMock HttpContextMock => this . httpContextMock ;
6968 }
7069}
Original file line number Diff line number Diff line change @@ -39,10 +39,13 @@ public static IActionResultTestBuilder<MethodResult> Which<TController>(
3939 {
4040 var actualBuilder = ( ControllerRouteTestBuilder < TController > ) builder ;
4141
42+ var routeContext = actualBuilder . RouteContext ;
4243 var actionCall = actualBuilder . ActionCallExpression ;
4344
4445 var whichControllerInstanceBuilder = new WhichControllerInstanceBuilder < TController > ( new ControllerTestContext
4546 {
47+ HttpContext = routeContext . HttpContext ,
48+ RouteData = routeContext . RouteData ,
4649 ComponentConstructionDelegate = ( ) => null ,
4750 MethodCall = actionCall
4851 } ) ;
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ protected ShouldMapTestBuilder(
4343 : this ( testContext )
4444 => this . actionCallExpression = actionCallExpression ;
4545
46- private RouteContext RouteContext => this . TestContext . RouteContext ;
46+ public RouteContext RouteContext => this . TestContext . RouteContext ;
4747
4848 /// <inheritdoc />
4949 public IAndResolvedRouteTestBuilder ToAction ( string actionName )
Original file line number Diff line number Diff line change @@ -8,10 +8,7 @@ public class RouteTestContext : HttpTestContext
88 {
99 private RouteContext routeContext ;
1010
11- public RouteTestContext ( )
12- {
13- this . SetAuthentication ( ) ;
14- }
11+ public RouteTestContext ( ) => this . SetAuthentication ( ) ;
1512
1613 public IRouter Router { get ; internal set ; }
1714
You can’t perform that action at this time.
0 commit comments