File tree Expand file tree Collapse file tree 4 files changed +11
-12
lines changed
MyTested.AspNetCore.Mvc.Abstractions/Internal/TestContexts
MyTested.AspNetCore.Mvc.Pipeline
MyTested.AspNetCore.Mvc.Routing Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 11
11
12
12
public abstract class HttpTestContext
13
13
{
14
- private HttpContextMock httpContextMock ;
15
14
private RouteData routeData ;
16
15
17
16
protected HttpTestContext ( )
18
17
{
19
18
TestHelper . ExecuteTestCleanup ( ) ;
20
- this . httpContextMock = TestHelper . CreateHttpContextMock ( ) ;
19
+ this . HttpContextMock = TestHelper . CreateHttpContextMock ( ) ;
21
20
}
22
21
23
22
public HttpContext HttpContext
24
23
{
25
- get => this . httpContextMock ;
24
+ get => this . HttpContextMock ;
26
25
27
26
set
28
27
{
29
28
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 ) ;
32
31
}
33
32
}
34
33
34
+ public HttpContextMock HttpContextMock { get ; private set ; }
35
+
35
36
public HttpRequest HttpRequest => this . HttpContext . Request ;
36
37
37
38
public HttpResponse HttpResponse => this . HttpContext . Response ;
@@ -64,7 +65,5 @@ public virtual RouteData RouteData
64
65
public ISession Session => this . HttpContext . Session ;
65
66
66
67
public abstract string ExceptionMessagePrefix { get ; }
67
-
68
- public HttpContextMock HttpContextMock => this . httpContextMock ;
69
68
}
70
69
}
Original file line number Diff line number Diff line change @@ -39,10 +39,13 @@ public static IActionResultTestBuilder<MethodResult> Which<TController>(
39
39
{
40
40
var actualBuilder = ( ControllerRouteTestBuilder < TController > ) builder ;
41
41
42
+ var routeContext = actualBuilder . RouteContext ;
42
43
var actionCall = actualBuilder . ActionCallExpression ;
43
44
44
45
var whichControllerInstanceBuilder = new WhichControllerInstanceBuilder < TController > ( new ControllerTestContext
45
46
{
47
+ HttpContext = routeContext . HttpContext ,
48
+ RouteData = routeContext . RouteData ,
46
49
ComponentConstructionDelegate = ( ) => null ,
47
50
MethodCall = actionCall
48
51
} ) ;
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ protected ShouldMapTestBuilder(
43
43
: this ( testContext )
44
44
=> this . actionCallExpression = actionCallExpression ;
45
45
46
- private RouteContext RouteContext => this . TestContext . RouteContext ;
46
+ public RouteContext RouteContext => this . TestContext . RouteContext ;
47
47
48
48
/// <inheritdoc />
49
49
public IAndResolvedRouteTestBuilder ToAction ( string actionName )
Original file line number Diff line number Diff line change @@ -8,10 +8,7 @@ public class RouteTestContext : HttpTestContext
8
8
{
9
9
private RouteContext routeContext ;
10
10
11
- public RouteTestContext ( )
12
- {
13
- this . SetAuthentication ( ) ;
14
- }
11
+ public RouteTestContext ( ) => this . SetAuthentication ( ) ;
15
12
16
13
public IRouter Router { get ; internal set ; }
17
14
You can’t perform that action at this time.
0 commit comments