public void CanSelectDynActionAndCreatesADynamicActionExecutor() { var controllerMeta = new ControllerMetaDescriptor(); var controller = new BaseClassController(); var context = new ControllerContext("baseclass", "", "action2", controllerMeta); context.DynamicActions.Add("action2", new DummyDynamicAction()); var action = selector.Select(engine, controller, context,ActionType.Sync); Assert.IsNotNull(action); Assert.IsInstanceOf(typeof(DynamicActionExecutor), action); }
public void CanSelectMethodAndCreatesAnActionMethodExecutorForIt() { var controllerMeta = new ControllerMetaDescriptor(); var controller = new BaseClassController(); var context = new ControllerContext("baseclass", "", "action1", controllerMeta); controllerMeta.Actions["action1"] = typeof(BaseClassController).GetMethod("Action1"); var action = selector.Select(engine, controller, context,ActionType.Sync); Assert.IsNotNull(action); Assert.IsInstanceOf(typeof(ActionMethodExecutor), action); }
public void Request_CreatesSessionfulHandler() { StringWriter writer = new StringWriter(); HttpResponse res = new HttpResponse( writer ); HttpRequest req = new HttpRequest( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Handlers/Files/simplerequest.txt" ), "http://localhost:1333/home/something", "" ); RouteMatch routeMatch = new RouteMatch(); HttpContext httpCtx = new HttpContext( req, res ); httpCtx.Items[ RouteMatch.RouteMatchKey ] = routeMatch; using ( _MockRepository.Record() ) { ControllerMetaDescriptor controllerDesc = new ControllerMetaDescriptor(); controllerDesc.ControllerDescriptor = new ControllerDescriptor( typeof( Controller ), "home", "", false ); Expect.Call( _ControllerFactoryMock.CreateController( "", "home" ) ).IgnoreArguments().Return( _ControllerMock ); Expect.Call( _ControllerDescriptorProviderMock.BuildDescriptor( _ControllerMock ) ).Return( controllerDesc ); Expect.Call( _ControllerContextFactoryMock.Create( "", "home", "something", controllerDesc, routeMatch ) ). Return( new ControllerContext() ); } using ( _MockRepository.Playback() ) { IHttpHandler handler = _HandlerFactory.GetHandler( httpCtx, "GET", "", "" ); Assert.IsNotNull( handler ); Assert.IsInstanceOfType( typeof( MonoRailHttpHandler ), handler ); } }
/// <summary> /// Creates the handler. /// </summary> /// <param name="controllerDesc">The controller descriptor.</param> /// <param name="engineContext">The engine context.</param> /// <param name="controller">The controller.</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// A new <see cref="T:System.Web.IHttpHandler"></see> object that processes the request. /// </returns> protected virtual IHttpAsyncHandler CreateAsyncHandler(ControllerMetaDescriptor controllerDesc, IEngineContext engineContext, IAsyncController controller, IControllerContext controllerContext) { if (IgnoresSession(controllerDesc.ControllerDescriptor)) { return new AsyncSessionlessMonoRailHttpHandler(engineContext, controller, controllerContext); } return new AsyncMonoRailHttpHandler(engineContext, controller, controllerContext); }