public void Establish_context() { _attribute = new PassParametersDuringRedirectAttribute(); _controller = new SampleController(); _filterContext = new ActionExecutingContext(); _filterContext.ActionParameters = new Dictionary<string, object>(); _filterContext.Controller = _controller; _someObject = new SomeObject {One = 1, Two = "two"}; _controller.TempData[PassParametersDuringRedirectAttribute.RedirectParameterPrefix + "param1"] = _someObject; _controller.TempData[PassParametersDuringRedirectAttribute.RedirectParameterPrefix + "param2"] = 5; }
public ActionResult Save(SomeObject updateModel, int someId) { return this.RedirectToAction(c => c.Index(updateModel, someId)); }
public ActionResult Index(SomeObject viewModel, int id) { return View(viewModel); }
public void Setup() { _filter = new PassParametersDuringRedirectAttribute(); _someObject = new SomeObject { One = 1, Two = "two" }; _fakeActionExecutingContext = new ActionExecutingContext() { Controller = new SampleController(), ActionParameters = new Dictionary<string, object>(), ActionDescriptor = GetActionDescriptorStubForIndexAction() }; var stubContext = MockRepository.GenerateStub<HttpContextBase>(); var stubRequest = MockRepository.GenerateStub<HttpRequestBase>(); stubRequest.RequestType = "GET"; stubContext.Stub(s => s.Request).Return(stubRequest); _fakeActionExecutingContext.HttpContext = stubContext; }
public void Setup() { _filter = new PassParametersDuringRedirectAttribute(); _someObject = new SomeObject {One = 1, Two = "two"}; }
public void OnActionExecuting_should_not_load_parameter_values_out_of_TempData_which_are_already_present_in_the_ActionParameters() { var otherSomeObject = new SomeObject(); var context = new ActionExecutingContext() { Controller = new SampleController(), ActionParameters = new Dictionary<string, object>{{"viewModel", otherSomeObject}, {"id",99} }, ActionDescriptor = GetActionDescriptorStubForIndexAction() }; context.Controller.TempData[PassParametersDuringRedirectAttribute.RedirectParameterPrefix + "viewModel"] = _someObject; context.Controller.TempData[PassParametersDuringRedirectAttribute.RedirectParameterPrefix + "id"] = 5; _filter.OnActionExecuting(context); context.ActionParameters["viewModel"].ShouldBeTheSameAs(otherSomeObject); context.ActionParameters["id"].ShouldEqual(99); }