public void _TestSetup()
        {
            using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
            {
                ContextRegistry.Clear();
                _context         = new MvcApplicationContext("file://objects.xml");
                _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjects.xml");

                ContextRegistry.RegisterContext(_context);
                ContextRegistry.RegisterContext(_mvcNamedContext);

                _factory = new SpringControllerFactory();

                //due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
                // see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
                _factory.InitializeWithControllerTypes(new[]
                {
                    typeof(FirstContainerRegisteredController),
                    typeof(SecondContainerRegisteredController),
                    typeof(NotInContainerController),
                    typeof(NamedContextController),
                });

                SpringControllerFactory.ApplicationContextName = string.Empty;
            }
        }
        public void _TestSetup()
        {
            using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
            {
                ContextRegistry.Clear();
                _context = new MvcApplicationContext("file://objects.xml");
                _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjects.xml");

                ContextRegistry.RegisterContext(_context);
                ContextRegistry.RegisterContext(_mvcNamedContext);

                _factory = new SpringControllerFactory();

                //due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
                // see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
                _factory.InitializeWithControllerTypes(new[]
                                                           {
                                                               typeof (FirstContainerRegisteredController),
                                                               typeof (SecondContainerRegisteredController),
                                                               typeof (NotInContainerController),
                                                               typeof (NamedContextController),
                                                           });

                SpringControllerFactory.ApplicationContextName = string.Empty;
            }
        }
Пример #3
0
        protected void Application_Start()
        {
            ObjectContainer.AddPrototypeDefinition(typeof(ISysCEFWorkLifetimeManager), typeof(SysCEFPerRequestWorkLifetimeManager));

            SpringControllerFactory.Init(ObjectContainer.Context);
            SpringControllerFactory.RegisterControllerPath(Assembly.GetExecutingAssembly(), "SysCEF.Web.Controllers");
            ControllerBuilder.Current.SetControllerFactory(new SpringControllerFactory());

            DataAccess.DependencyConfigurator.ConfigureDependencies();
            DAO.DependencyConfigurator.ConfigureSqlRepositories();

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
        public void Setup()
        {
            string objectXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> " +
                               "  <objects xmlns=\"http://www.springframework.net\" " +
                               "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
                               "    xsi:schemaLocation=\"http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd\"> " +
                               "    <object id=\"SimpleController\" singleton=\"false\" type=\"" + typeof(SpringSimpleController).FullName + "\"/> " +
                               "    <object id=\"DisposableController\" singleton=\"false\" type=\"" + typeof(SpringDisposableController).FullName + "\"/> " +
                               "    <object id=\"TestAreaSimpleController\" singleton=\"false\" type=\"" + typeof(TestArea.SpringSimpleController).FullName + "\"/>" +
                               "  </objects>";

            var stream  = new MemoryStream(Encoding.Default.GetBytes(objectXml));
            var factory = new XmlObjectFactory(new InputStreamResource(stream, "In memory xml"));

            SpringControllerFactory.Configure(factory);

            _factory = new SpringControllerFactory();

            _context = new RequestContext(MvcMockHelpers.DynamicHttpContextBase(), new RouteData());
        }
 public void Should_throw_when_not_configured()
 {
     SpringControllerFactory.Configure(null);
     Assert.Throws <ArgumentException>(() => _factory.CreateController(_context, "Simple"));
 }