6
6
using FluentAssertions ;
7
7
using Http ;
8
8
using Moq ;
9
+ using System . Collections . Generic ;
9
10
using System . Linq ;
10
11
using Versioning ;
11
12
using Xunit ;
12
13
13
14
public class ReportApiVersionsAttributeTest
14
15
{
15
- static ActionExecutedContext CreateContext ( ApiVersionModel model )
16
+ static ActionExecutingContext CreateContext ( ApiVersionModel model )
16
17
{
17
18
var headers = new HeaderDictionary ( ) ;
18
19
var response = new Mock < HttpResponse > ( ) ;
19
20
var httpContext = new Mock < HttpContext > ( ) ;
20
21
var action = new ActionDescriptor ( ) ;
21
22
var actionContext = new ActionContext ( httpContext . Object , new RouteData ( ) , action ) ;
23
+ var filters = new IFilterMetadata [ 0 ] ;
24
+ var actionArguments = new Dictionary < string , object > ( ) ;
25
+ var controller = default ( object ) ;
22
26
23
27
response . SetupGet ( r => r . Headers ) . Returns ( headers ) ;
24
28
httpContext . SetupGet ( c => c . Response ) . Returns ( response . Object ) ;
25
29
action . SetProperty ( model ) ;
26
30
27
- return new ActionExecutedContext ( actionContext , new IFilterMetadata [ 0 ] , null ) ;
31
+ return new ActionExecutingContext ( actionContext , filters , actionArguments , controller ) ;
28
32
}
29
33
30
34
[ Fact ]
31
- public void on_action_executed_should_add_version_headers ( )
35
+ public void on_action_executing_should_add_version_headers ( )
32
36
{
33
37
// arrange
34
38
var supported = new [ ] { new ApiVersion ( 1 , 0 ) , new ApiVersion ( 2 , 0 ) } ;
@@ -38,7 +42,7 @@ public void on_action_executed_should_add_version_headers()
38
42
var attribute = new ReportApiVersionsAttribute ( ) ;
39
43
40
44
// act
41
- attribute . OnActionExecuted ( context ) ;
45
+ attribute . OnActionExecuting ( context ) ;
42
46
43
47
// assert
44
48
context . HttpContext . Response . Headers [ "api-supported-versions" ] . Single ( ) . Should ( ) . Be ( "1.0, 2.0" ) ;
@@ -53,7 +57,7 @@ public void on_action_executing_should_not_add_headers_for_versionX2Dneutral_con
53
57
var attribute = new ReportApiVersionsAttribute ( ) ;
54
58
55
59
// act
56
- attribute . OnActionExecuted ( context ) ;
60
+ attribute . OnActionExecuting ( context ) ;
57
61
58
62
59
63
// assert
0 commit comments