public void Invoke_should_execute_the_selected_action() { var sink = new ActionExecutionSink(); var context = new ControllerExecutionContext(null, new ControllerContext(), this, new RouteData(), null) { SelectedAction = new TestActionDescriptor(FakeAction) }; sink.Invoke(context); Assert.IsTrue(invoked); }
public void Invoke_should_bind_parameters_using_request_data() { var http = new Mock <HttpContextBase>(); var sink = new ActionExecutionSink(); http.SetupGet(ctx => ctx.Request.Params).Returns(new NameValueCollection { { "a", "the value" }, { "b", "123" } }); var context = new ControllerExecutionContext(http.Object, new ControllerContext(), this, new RouteData(), null) { SelectedAction = new MethodInfoActionDescriptor(GetType().GetMethod("WithPrimitiveParametersAction")) }; sink.Invoke(context); Assert.IsTrue(invoked); Assert.AreEqual("the value", _a); Assert.AreEqual(123, _b); }
public void Invoked_should_bind_HttpContext_and_ControllerContext() { var controllerContext = new ControllerContext(); var http = new Mock <HttpContextBase>(); var sink = new ActionExecutionSink(); http.SetupGet(ctx => ctx.Request.Params).Returns(new NameValueCollection()); var routeData = new RouteData(); var context = new ControllerExecutionContext(http.Object, controllerContext, this, routeData, null) { SelectedAction = new MethodInfoActionDescriptor(GetType().GetMethod("WithContextParametersAction")) }; sink.Invoke(context); Assert.IsTrue(invoked); Assert.AreSame(http.Object, _httpContext); Assert.AreSame(controllerContext, _controllerContext); }
public void Invoked_should_bind_HttpContext_and_ControllerContext() { var controllerContext = new ControllerContext(); var http = new Mock<HttpContextBase>(); var sink = new ActionExecutionSink(); http.SetupGet(ctx => ctx.Request.Params).Returns(new NameValueCollection()); var routeData = new RouteData(); var context = new ControllerExecutionContext(http.Object, controllerContext, this, routeData, null) { SelectedAction = new MethodInfoActionDescriptor(GetType().GetMethod("WithContextParametersAction")) }; sink.Invoke(context); Assert.IsTrue(invoked); Assert.AreSame(http.Object, _httpContext); Assert.AreSame(controllerContext, _controllerContext); }
public void Invoked_should_do_a_custom_databind_if_parameter_is_decorated_with_a_CustomBinder() { var controllerContext = new ControllerContext(); var http = new Mock <HttpContextBase>(); var sink = new ActionExecutionSink(); http.SetupGet(ctx => ctx.Request.Params).Returns(new NameValueCollection { { "user.Name", "Lyle" } }); var routeData = new RouteData(); var context = new ControllerExecutionContext(http.Object, controllerContext, this, routeData, null) { SelectedAction = new MethodInfoActionDescriptor(GetType().GetMethod("WithCustomBinding")) }; sink.Invoke(context); Assert.IsTrue(invoked); Assert.AreEqual("Lyle", _user.Name); }
public void Invoked_should_do_a_custom_databind_if_parameter_is_decorated_with_a_CustomBinder() { var controllerContext = new ControllerContext(); var http = new Mock<HttpContextBase>(); var sink = new ActionExecutionSink(); http.SetupGet(ctx => ctx.Request.Params).Returns(new NameValueCollection{{"user.Name", "Lyle"}}); var routeData = new RouteData(); var context = new ControllerExecutionContext(http.Object, controllerContext, this, routeData, null) { SelectedAction = new MethodInfoActionDescriptor(GetType().GetMethod("WithCustomBinding")) }; sink.Invoke(context); Assert.IsTrue(invoked); Assert.AreEqual("Lyle", _user.Name); }
public void Invoke_should_execute_the_selected_action() { var sink = new ActionExecutionSink(); var context = new ControllerExecutionContext(null, new ControllerContext(), this, new RouteData(), null) { SelectedAction = new TestActionDescriptor(FakeAction) }; sink.Invoke(context); Assert.IsTrue(invoked); }
public void Invoke_should_bind_parameters_using_routing_data() { var http = new Mock<HttpContextBase>(); var sink = new ActionExecutionSink(); http.SetupGet(ctx => ctx.Request.Params).Returns(new NameValueCollection()); var routeData = new RouteData(); routeData.Values.Add("a", "other value"); routeData.Values.Add("b", "123"); var context = new ControllerExecutionContext(http.Object, new ControllerContext(), this, routeData, null) { SelectedAction = new MethodInfoActionDescriptor(GetType().GetMethod("WithPrimitiveParametersAction")) }; sink.Invoke(context); Assert.IsTrue(invoked); Assert.AreEqual("other value", _a); }