@@ -11,6 +11,35 @@ namespace System.Web.Http.Tracing.Tracers
1111{
1212 public class ActionValueBinderTracerTest
1313 {
14+ [ Fact ]
15+ public void GetBinding_Returns_HttpActionBindingTracer ( )
16+ {
17+ // Arrange
18+ Mock < HttpActionDescriptor > mockActionDescriptor = new Mock < HttpActionDescriptor > ( ) { CallBase = true } ;
19+ mockActionDescriptor . Setup ( a => a . ActionName ) . Returns ( "test" ) ;
20+ mockActionDescriptor . Setup ( a => a . GetParameters ( ) ) . Returns ( new Collection < HttpParameterDescriptor > ( new HttpParameterDescriptor [ 0 ] ) ) ;
21+
22+ Mock < HttpParameterDescriptor > mockParameterDescriptor = new Mock < HttpParameterDescriptor > ( ) { CallBase = true } ;
23+ Mock < HttpParameterBinding > mockParameterBinding = new Mock < HttpParameterBinding > ( mockParameterDescriptor . Object ) { CallBase = true } ;
24+ HttpActionBinding actionBinding = new HttpActionBinding ( mockActionDescriptor . Object , new HttpParameterBinding [ ] { mockParameterBinding . Object } ) ;
25+
26+ HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor ( new HttpConfiguration ( ) , "controller" , typeof ( ApiController ) ) ;
27+
28+ HttpControllerContext controllerContext = ContextUtil . CreateControllerContext ( request : new HttpRequestMessage ( ) ) ;
29+ controllerContext . ControllerDescriptor = controllerDescriptor ;
30+
31+ Mock < IActionValueBinder > mockBinder = new Mock < IActionValueBinder > ( ) { CallBase = true } ;
32+ mockBinder . Setup ( b => b . GetBinding ( It . IsAny < HttpActionDescriptor > ( ) ) ) . Returns ( actionBinding ) ;
33+ ActionValueBinderTracer tracer = new ActionValueBinderTracer ( mockBinder . Object , new TestTraceWriter ( ) ) ;
34+
35+ // Act
36+ HttpActionBinding actualBinding = ( ( IActionValueBinder ) tracer ) . GetBinding ( mockActionDescriptor . Object ) ;
37+
38+ // Assert
39+ Assert . IsType < HttpActionBindingTracer > ( actualBinding ) ;
40+ Assert . Same ( mockActionDescriptor . Object , actualBinding . ActionDescriptor ) ;
41+ }
42+
1443 [ Fact ]
1544 public void GetBinding_Invokes_Inner_And_Returns_ActionBinder_With_Tracing_HttpParameterBinding ( )
1645 {
0 commit comments