public void ProcessRequestAddsServerHeaderCallsExecute() {
            // Arrange
            Mock<HttpContextBase> contextMock = new Mock<HttpContextBase>();
            contextMock.ExpectMvcVersionResponseHeader().Verifiable();

            RouteData rd = new RouteData();
            rd.Values.Add("controller", "foo");
            RequestContext requestContext = new RequestContext(contextMock.Object, rd);
            MvcHandler mvcHandler = new MvcHandler(requestContext);

            Mock<ControllerBase> controllerMock = new Mock<ControllerBase>();
            controllerMock.Protected().Setup("Execute", requestContext).Verifiable();

            ControllerBuilder cb = new ControllerBuilder();
            Mock<IControllerFactory> controllerFactoryMock = new Mock<IControllerFactory>();
            controllerFactoryMock.Setup(o => o.CreateController(requestContext, "foo")).Returns(controllerMock.Object);
            controllerFactoryMock.Setup(o => o.ReleaseController(controllerMock.Object));
            cb.SetControllerFactory(controllerFactoryMock.Object);
            mvcHandler.ControllerBuilder = cb;

            // Act
            mvcHandler.ProcessRequest(contextMock.Object);

            // Assert
            contextMock.Verify();
            controllerMock.Verify();
        }
Beispiel #2
0
        protected internal virtual void ProcessRequest(HttpContextBase httpContext)
        {
            AddVersionHeader(httpContext);

            // Get the controller type
            string controllerName = RequestContext.RouteData.GetRequiredString("controller");

            // Instantiate the controller and call Execute
            IControllerFactory factory    = ControllerBuilder.GetControllerFactory();
            IController        controller = factory.CreateController(RequestContext, controllerName);

            if (controller == null)
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentUICulture,
                              MvcResources.ControllerBuilder_FactoryReturnedNull,
                              factory.GetType(),
                              controllerName));
            }
            try {
                controller.Execute(RequestContext);
            }
            finally {
                factory.ReleaseController(controller);
            }
        }
        public void ProcessRequestWithNormalControlFlowForAsynchronousController() {
            // Arrange
            Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();
            mockHttpContext.ExpectMvcVersionResponseHeader().Verifiable();

            RequestContext requestContext = new RequestContext(mockHttpContext.Object, GetRouteData());
            MvcAsyncHandler handler = new MvcAsyncHandler(requestContext);

            MockAsyncResult asyncResult = new MockAsyncResult();
            Mock<IAsyncController> mockController = new Mock<IAsyncController>();
            mockController.Expect(c => c.BeginExecute(requestContext, It.IsAny<AsyncCallback>(), It.IsAny<object>())).Returns(asyncResult).Verifiable();
            mockController.Expect(c => c.EndExecute(asyncResult)).Verifiable();
            mockController.As<IDisposable>().Expect(c => c.Dispose()).AtMostOnce().Verifiable();

            ControllerBuilder builder = new ControllerBuilder();
            builder.SetControllerFactory(new SimpleControllerFactory(mockController.Object));
            handler.ControllerBuilder = builder;

            // Act
            IAsyncResult returnedAsyncResult = handler.BeginProcessRequest(mockHttpContext.Object, null, null);
            handler.EndProcessRequest(returnedAsyncResult);

            mockHttpContext.Verify();
            mockController.Verify();
        }
        private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory)
        {
            // If request validation has already been enabled, make it lazy. This allows attributes like [HttpPost] (which looks
            // at Request.Form) to work correctly without triggering full validation.
            // Tolerate null HttpContext for testing.
            HttpContext currentContext = HttpContext.Current;

            if (currentContext != null)
            {
                bool?isRequestValidationEnabled = ValidationUtility.IsValidationEnabled(currentContext);
                if (isRequestValidationEnabled == true)
                {
                    ValidationUtility.EnableDynamicValidation(currentContext);
                }
            }

            AddVersionHeader(httpContext);
            RemoveOptionalRoutingParameters();

            // Get the controller type
            string controllerName = RequestContext.RouteData.GetRequiredString("controller");

            // Instantiate the controller and call Execute
            factory    = ControllerBuilder.GetControllerFactory();
            controller = factory.CreateController(RequestContext, controllerName);
            if (controller == null)
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              MvcResources.ControllerBuilder_FactoryReturnedNull,
                              factory.GetType(),
                              controllerName));
            }
        }
        public void ProcessRequestWhereControllerBeginExecuteThrows() {
            // Arrange
            Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();
            mockHttpContext.ExpectMvcVersionResponseHeader().Verifiable();

            RequestContext requestContext = new RequestContext(mockHttpContext.Object, GetRouteData());
            MvcAsyncHandler handler = new MvcAsyncHandler(requestContext);

            Mock<IAsyncController> mockController = new Mock<IAsyncController>();
            mockController.Expect(c => c.BeginExecute(requestContext, It.IsAny<AsyncCallback>(), It.IsAny<object>())).Throws(new InvalidOperationException("Some exception text.")).Verifiable();
            mockController.As<IDisposable>().Expect(c => c.Dispose()).AtMostOnce().Verifiable();

            ControllerBuilder builder = new ControllerBuilder();
            builder.SetControllerFactory(new SimpleControllerFactory(mockController.Object));
            handler.ControllerBuilder = builder;

            // Act
            ExceptionHelper.ExpectInvalidOperationException(
                delegate {
                    handler.BeginProcessRequest(mockHttpContext.Object, null, null);
                },
                @"Some exception text.");

            mockHttpContext.Verify();
            mockController.Verify();
        }
        public void ProcessRequestWithDisabledServerHeaderOnlyCallsExecute() {
            bool oldResponseHeaderValue = MvcHandler.DisableMvcResponseHeader;
            try {
                // Arrange
                MvcHandler.DisableMvcResponseHeader = true;
                Mock<HttpContextBase> contextMock = new Mock<HttpContextBase>();

                RouteData rd = new RouteData();
                rd.Values.Add("controller", "foo");
                RequestContext requestContext = new RequestContext(contextMock.Object, rd);
                MvcHandler mvcHandler = new MvcHandler(requestContext);

                Mock<ControllerBase> controllerMock = new Mock<ControllerBase>();
                controllerMock.Protected().Expect("Execute", requestContext).Verifiable();

                ControllerBuilder cb = new ControllerBuilder();
                Mock<IControllerFactory> controllerFactoryMock = new Mock<IControllerFactory>();
                controllerFactoryMock.Expect(o => o.CreateController(requestContext, "foo")).Returns(controllerMock.Object);
                controllerFactoryMock.Expect(o => o.ReleaseController(controllerMock.Object));
                cb.SetControllerFactory(controllerFactoryMock.Object);
                mvcHandler.ControllerBuilder = cb;

                // Act
                mvcHandler.ProcessRequest(contextMock.Object);

                // Assert
                controllerMock.Verify();
            }
            finally {
                MvcHandler.DisableMvcResponseHeader = oldResponseHeaderValue;
            }
        }
        public void Should_be_able_to_register_controller_factory()
        {
            var builder = new ControllerBuilder();

            new RegisterControllerFactory(adapter.Object, builder).Execute();

            Assert.Same(controllerFactory.Object, builder.GetControllerFactory());
        }
        public ControllerBuilderAdaptor(
            ControllerBuilder controllerBuilder
            )
        {
            if (controllerBuilder == null)
                throw new ArgumentNullException("controllerBuilder");

            this.controllerBuilder = controllerBuilder;
        }
 //MiniProfiler miniProfiler)
 public RegisterControllerFactoryWithMvcBootstrapperTask(IServiceLocator serviceLocator,
                                                         ControllerBuilder currentControllerBuilder,
                                                         IFeatureManifest<Feature> featureManifest)
 {
     _serviceLocator = serviceLocator;
     _currentControllerBuilder = currentControllerBuilder;
     _featureManifest = featureManifest;
     //_miniProfiler = miniProfiler;
 }
Beispiel #10
0
        public void ControllerBuilderReturnsDefaultControllerBuilderByDefault() {
            // Arrange
            ControllerBuilder cb = new ControllerBuilder();

            // Act
            IControllerFactory cf = cb.GetControllerFactory();

            // Assert
            Assert.IsInstanceOfType(cf, typeof(DefaultControllerFactory));
        }
Beispiel #11
0
        public static void RegisterControllerFactory(ControllerBuilder controllerBuilder, IEngine engine)
        {
            engine.RegisterControllers(Assembly.GetExecutingAssembly());

            var controllerFactory = engine.Resolve<ControllerFactoryConfigurator>()
                //.NotFound<StartController>(sc => sc.NotFound())
                .ControllerFactory;

            controllerBuilder.SetControllerFactory(controllerFactory);
        }
		public void RegisterControllerFactory(ControllerBuilder controllerBuilder, IEngine engine)
		{
			engine.RegisterAllControllers();

			var controllerFactory = engine.Resolve<ControllerFactoryConfigurator>()
				.NotFound<StartController>(sc => sc.NotFound())
				.ControllerFactory;

			controllerBuilder.SetControllerFactory(controllerFactory);
		}
		public static void RegisterControllerFactory(ControllerBuilder controllerBuilder, IEngine engine)
		{
			// Registers controllers in the solution for dependency injection using the IoC container provided by N2
			engine.RegisterAllControllers();

			var controllerFactory = engine.Resolve<ControllerFactoryConfigurator>()
				.NotFound<Controllers.StartPageController>(sc => sc.NotFound())
				.ControllerFactory;

			controllerBuilder.SetControllerFactory(controllerFactory);
		}
        public void Should_not_register_controller_factory_when_excluded()
        {
            RegisterControllerFactory.Excluded = true;
            DependencyResolver.SetResolver(null);

            var builder = new ControllerBuilder();

            new RegisterControllerFactory(adapter.Object, builder).Execute();

            Assert.NotSame(controllerFactory.Object, builder.GetControllerFactory());
        }
Beispiel #15
0
        public void CreateControllerWithFactoryInstanceReturnsInstance() {
            // Arrange
            ControllerBuilder cb = new ControllerBuilder();
            DefaultControllerFactory factory = new DefaultControllerFactory();
            cb.SetControllerFactory(factory);

            // Act
            IControllerFactory cf = cb.GetControllerFactory();

            // Assert
            Assert.AreSame(factory, cf);
        }
 public DefaultOrchardHost(
     IShellSettingsManager shellSettingsManager,
     IShellContextFactory shellContextFactory,
     IRunningShellTable runningShellTable,
     ControllerBuilder controllerBuilder)
 {
     //_containerProvider = containerProvider;
     _shellSettingsManager = shellSettingsManager;
     _shellContextFactory = shellContextFactory;
     _runningShellTable = runningShellTable;
     _controllerBuilder = controllerBuilder;
     Logger = NullLogger.Instance;
 }
        public static void Start(HttpConfiguration config, ControllerBuilder builder)
        {
            // innitialize the IoC using Structure Map.
            IoC.Initialize();

            var container = ObjectFactory.Container;

            // Standard settings for SM for MVC4.
            config.DependencyResolver = new SmDependencyResolver(container);

            // Used as a test to overide some issues with Injecting dependenices on Api controllers.
            // Though the Api controllers are not used in this version of the application
            builder.SetControllerFactory(new StructureMapControllerFactory());
        }
Beispiel #18
0
        public static void RegisterMvc(ControllerBuilder controllerBuilder, GlobalFilterCollection globalFilters)
        {
            //controllers
            Container.Register<IController, HomeController>("Home").AsMultiInstance();

            //filters
            var filters = Container.ResolveAll<IMvcFilter>();
            foreach (var filter in filters)
            {
                globalFilters.Add(filter);
            }

            //controller factory
            controllerBuilder.SetControllerFactory(new TinyIocControllerFactory(Container));
        }
        public void Init() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);

            _controllerBuilder = new ControllerBuilder();
            _routeCollection = new RouteCollection();
            _modelBinderDictionary = new ModelBinderDictionary();
            _viewEngineCollection = new ViewEngineCollection { new WebFormViewEngine() };

            _container = OrchardStarter.CreateHostContainer(
                builder => {
                    builder.RegisterInstance(new StubShellSettingsLoader()).As<IShellSettingsManager>();
                    builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
                    builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
                    builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>();
                    builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
                    builder.RegisterType<StubVirtualPathMonitor>().As<IVirtualPathMonitor>();
                    builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
                    builder.RegisterInstance(_controllerBuilder);
                    builder.RegisterInstance(_routeCollection);
                    builder.RegisterInstance(_modelBinderDictionary);
                    builder.RegisterInstance(_viewEngineCollection);
                    builder.RegisterAutoMocking()
                        .Ignore<IExtensionFolders>()
                        .Ignore<IRouteProvider>()
                        .Ignore<IHttpRouteProvider>()
                        .Ignore<IModelBinderProvider>()
                        .Ignore<IWorkContextEvents>()
                        .Ignore<IOwinMiddlewareProvider>();
                });
            _lifetime = _container.BeginLifetimeScope();

            _container.Mock<IContainerProvider>()
                .SetupGet(cp => cp.ApplicationContainer).Returns(_container);
            _container.Mock<IContainerProvider>()
                .SetupGet(cp => cp.RequestLifetime).Returns(_lifetime);
            _container.Mock<IContainerProvider>()
                .Setup(cp => cp.EndRequestLifetime()).Callback(() => _lifetime.Dispose());

            _container.Mock<IShellDescriptorManager>()
                .Setup(cp => cp.GetShellDescriptor()).Returns(default(ShellDescriptor));

            _container.Mock<IOrchardShellEvents>()
                .Setup(e => e.Activated());

            _container.Mock<IOrchardShellEvents>()
                .Setup(e => e.Terminating()).Callback(() => new object());
        }
Beispiel #20
0
        public void CreateControllerWithFactoryThatCannotBeCreatedThrows() {
            // Arrange
            ControllerBuilder cb = new ControllerBuilder();
            cb.SetControllerFactory(typeof(ControllerFactoryThrowsFromConstructor));

            // Act
            ExceptionHelper.ExpectException<InvalidOperationException>(
                delegate {
                    RequestContext reqContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData());
                    reqContext.RouteData.Values["controller"] = "foo";
                    MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader(reqContext) {
                        ControllerBuilder = cb
                    };
                    handler.ProcessRequest(reqContext.HttpContext);
                },
                "An error occurred when trying to create the IControllerFactory 'System.Web.Mvc.Test.ControllerBuilderTest+ControllerFactoryThrowsFromConstructor'. Make sure that the controller factory has a public parameterless constructor.");
        }
Beispiel #21
0
        public void CreateControllerWithFactoryThatReturnsNullThrows() {
            // Arrange
            ControllerBuilder cb = new ControllerBuilder();
            cb.SetControllerFactory(typeof(ControllerFactoryReturnsNull));

            // Act
            ExceptionHelper.ExpectException<InvalidOperationException>(
                delegate {
                    RequestContext reqContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData());
                    reqContext.RouteData.Values["controller"] = "boo";
                    MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader(reqContext) {
                        ControllerBuilder = cb
                    };
                    handler.ProcessRequest(reqContext.HttpContext);
                },
                "The IControllerFactory 'System.Web.Mvc.Test.ControllerBuilderTest+ControllerFactoryReturnsNull' did not return a controller for the name 'boo'.");
        }
        public void Init() {
            _controllerBuilder = new ControllerBuilder();
            _routeCollection = new RouteCollection();
            _modelBinderDictionary = new ModelBinderDictionary();
            _viewEngineCollection = new ViewEngineCollection { new WebFormViewEngine() };

            _container = OrchardStarter.CreateHostContainer(
                builder => {
                    builder.RegisterInstance(new StubShellSettingsLoader()).As<IShellSettingsManager>();
                    builder.RegisterType<StubContainerProvider>().As<IContainerProvider>().InstancePerLifetimeScope();
                    builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
                    builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
                    builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>();
                    builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
                    builder.RegisterInstance(_controllerBuilder);
                    builder.RegisterInstance(_routeCollection);
                    builder.RegisterInstance(_modelBinderDictionary);
                    builder.RegisterInstance(_viewEngineCollection);
                    builder.RegisterAutoMocking()
                        .Ignore<IExtensionFolders>()
                        .Ignore<IRouteProvider>()
                        .Ignore<IModelBinderProvider>();
                });
            _lifetime = _container.BeginLifetimeScope();

            _container.Mock<IContainerProvider>()
                .SetupGet(cp => cp.ApplicationContainer).Returns(_container);
            _container.Mock<IContainerProvider>()
                .SetupGet(cp => cp.RequestLifetime).Returns(_lifetime);
            _container.Mock<IContainerProvider>()
                .Setup(cp => cp.EndRequestLifetime()).Callback(() => _lifetime.Dispose());

            _container.Mock<IShellDescriptorManager>()
                .Setup(cp => cp.GetShellDescriptor()).Returns(default(ShellDescriptor));

            var temp = Path.GetTempFileName();
            File.Delete(temp);
            Directory.CreateDirectory(temp);

            _container.Resolve<IAppDataFolder>()
                .SetBasePath(temp);

            var updater = new ContainerUpdater();
            updater.RegisterInstance(_container).SingleInstance();
            updater.Update(_lifetime);
        }
Beispiel #23
0
        public void CreateControllerWithFactoryThatThrowsDoesNothingSpecial() {
            // Arrange
            ControllerBuilder cb = new ControllerBuilder();
            cb.SetControllerFactory(typeof(ControllerFactoryThrows));

            // Act
            ExceptionHelper.ExpectException<Exception>(
                delegate {
                    RequestContext reqContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData());
                    reqContext.RouteData.Values["controller"] = "foo";
                    MvcHandlerWithNoVersionHeader handler = new MvcHandlerWithNoVersionHeader(reqContext) {
                        ControllerBuilder = cb
                    };
                    handler.ProcessRequest(reqContext.HttpContext);
                },
                "ControllerFactoryThrows");
        }
        public void GetHttpHandlerWithValidControllerDoesNotChangeRouteTest()
        {
            // Arrange
            var mockController = new Mock<ControllerBase>(MockBehavior.Strict);
            var expected = "fooController";

            var builder = new ControllerBuilder();
            builder.SetControllerFactory(new SimpleControllerFactory(mockController.Object));

            var contextMock = new Mock<HttpContextBase>();
            var requestContext = new RequestContext(contextMock.Object, new RouteData());
            requestContext.RouteData.Values["controller"] = expected;

            // act
            var handler = new PhunMvcRouteHandler() { ControllerBuilder = builder };
            handler.PreHandleRequestInternal(requestContext);

            // Assert
            Assert.AreEqual(expected, requestContext.RouteData.Values["controller"]);
        }
        public void SetSessionStateMode_HandlerIsMvcHandler_ControllerHasNoAttribute_SetsDefault() {
            // Arrange
            RequestContext requestContext = GetRequestContext();
            IHttpHandler originalHttpHandler = requestContext.HttpContext.Handler;

            Mock<IControllerFactory> mockControllerFactory = new Mock<IControllerFactory>();
            mockControllerFactory.Expect(o => o.CreateController(requestContext, "home")).Returns(new ControllerWithoutAttribute());

            ControllerBuilder controllerBuilder = new ControllerBuilder();
            controllerBuilder.SetControllerFactory(new MvcDynamicSessionControllerFactory(mockControllerFactory.Object));
            MvcDynamicSessionModule module = new MvcDynamicSessionModule() {
                ControllerBuilder = controllerBuilder
            };

            // Act
            module.SetSessionStateMode(requestContext.HttpContext, SimpleDynamicSessionStateConfigurator.ExpectMode(ControllerSessionState.Default));

            // Assert
            Assert.AreEqual(2, requestContext.HttpContext.Items.Count, "Cache + factory weren't properly added to Items.");
        }
        public void ProcessRequestThrowsIfControllerNotFound() {
            // Arrange
            Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();
            mockHttpContext.ExpectMvcVersionResponseHeader().Verifiable();

            RequestContext requestContext = new RequestContext(mockHttpContext.Object, GetRouteData());
            MvcAsyncHandler handler = new MvcAsyncHandler(requestContext);

            ControllerBuilder builder = new ControllerBuilder();
            builder.SetControllerFactory(new SimpleControllerFactory(null));
            handler.ControllerBuilder = builder;

            // Act & assert
            ExceptionHelper.ExpectInvalidOperationException(
                delegate {
                    handler.BeginProcessRequest(mockHttpContext.Object, null, null);
                },
                @"The IControllerFactory 'Microsoft.Web.Mvc.Test.MvcAsyncHandlerTest+SimpleControllerFactory' did not return a controller for a controller named 'Foo'.");

            mockHttpContext.Verify();
        }
Beispiel #27
0
        private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory)
        {
            AddVersionHeader(httpContext);
            RemoveOptionalRoutingParameters();

            // Get the controller type
            string controllerName = RequestContext.RouteData.GetRequiredString("controller");

            // Instantiate the controller and call Execute
            factory    = ControllerBuilder.GetControllerFactory();
            controller = factory.CreateController(RequestContext, controllerName);
            if (controller == null)
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentUICulture,
                              MvcResources.ControllerBuilder_FactoryReturnedNull,
                              factory.GetType(),
                              controllerName));
            }
        }
        public static void Install(ControllerBuilder builder)
        {
            if ( ViewFormats.Count == 0 )
            {
                throw new InvalidOperationException(
                    "You must enable at least one set of view locations or add your own."
                    );
            }

            if ( FileExtensions.Count == 0 )
            {
                FileExtensions.Add( "cshtml" );
                FileExtensions.Add( "vbhtml" );
            }

            var engine = new EnhancedViewLocationsViewEngine();
            engine.SetFullViewFormats( ViewFormats );
            engine.SetPartialViewFormats( ViewFormats );
            engine.SetFileExtensions( FileExtensions );

            ViewEngines.Engines.Insert( 0, engine );
        }
        public void PossiblyReleaseController_CorrectFactory_ReleasesController() {
            // Arrange
            RequestContext requestContext = GetRequestContext();
            IHttpHandler originalHttpHandler = requestContext.HttpContext.Handler;
            Controller controller = new ControllerReadOnlySession();

            Mock<IControllerFactory> mockControllerFactory = new Mock<IControllerFactory>();
            mockControllerFactory.Expect(o => o.CreateController(requestContext, "home")).Returns(controller);
            mockControllerFactory.Expect(o => o.ReleaseController(controller)).Verifiable();

            ControllerBuilder controllerBuilder = new ControllerBuilder();
            controllerBuilder.SetControllerFactory(new MvcDynamicSessionControllerFactory(mockControllerFactory.Object));
            MvcDynamicSessionModule module = new MvcDynamicSessionModule() {
                ControllerBuilder = controllerBuilder
            };

            // Act
            module.SetSessionStateMode(requestContext.HttpContext, SimpleDynamicSessionStateConfigurator.ExpectMode(ControllerSessionState.ReadOnly));
            MvcDynamicSessionModule.PossiblyReleaseController(requestContext.HttpContext);

            // Assert
            mockControllerFactory.Verify();
        }
Beispiel #30
0
        public void CreateControllerWithFactoryTypeReturnsValidType() {
            // Arrange
            ControllerBuilder cb = new ControllerBuilder();
            cb.SetControllerFactory(typeof(MockControllerFactory));

            // Act
            IControllerFactory cf = cb.GetControllerFactory();

            // Assert
            Assert.IsInstanceOfType(cf, typeof(MockControllerFactory));
        }
 public static void RegisterControllerFactory(ControllerBuilder controllerBuilder, IEngine engine)
 {
     //// Registers controllers in the solution for dependency injection using the IoC container provided by N2
     //engine.RegisterAllControllers();
     //controllerBuilder.SetControllerFactory(engine.GetControllerFactory());
 }
Beispiel #32
0
 public static FluentlyWindsor.FluentWindsor RegisterMvcControllers(this FluentlyWindsor.FluentWindsor fluentWindsor, System.Web.Mvc.ControllerBuilder controllerBuilder, params string[] controllerNamespaces)
 {
     FluentWindsorExtensionsConstants.ControllerNamespaces = controllerNamespaces;
     ControllerBuilder.Current.SetControllerFactory(new FluentWindsorMvcControllerFactory(FluentlyWindsor.FluentWindsor.ServiceLocator));
     return(fluentWindsor.WithTypesInheriting <Controller>(
                (x, y) => x.RegisterIfNotAlready(Component.For(y).Named(y.Name.Replace("Controller", "_MVC")).LifeStyle.PerWebRequest)));
 }
 public ControllerFactoryConfigurator(ControllerBuilder controllerBuilder)
 {
     _controllerBuilder = controllerBuilder;
 }
 private static DefaultControllerFactory GetDefaultControllerFactory(params string[] namespaces) {
     ControllerBuilder builder = new ControllerBuilder();
     builder.DefaultNamespaces.UnionWith(namespaces);
     return new DefaultControllerFactory() { ControllerBuilder = builder };
 }