public void Setup() { _container = MockRepository.GenerateStub<IContainer>(); _routeData = new RouteData(); _requestContext = new RequestContext(MockRepository.GenerateStub<HttpContextBase>(), _routeData); _testController = new TestController(); _structureMapControllerFactory = new StructureMapControllerFactory(_container); }
protected void Application_Start() { //ObjectFactory.Initialize(init => //{ // init.Scan(x => // { // x.AssemblyContainingType(typeof(IAsyncRequestHandler<,>)); // x.AssemblyContainingType(typeof(IAsyncRequest<>)); // x.LookForRegistries(); // x.Assembly("Sogeti.Capstone.Domain"); // x.WithDefaultConventions(); // x.TheCallingAssembly(); // x.AddAllTypesOf(typeof(IAsyncRequest<>)); // x.AddAllTypesOf(typeof(IAsyncRequestHandler<,>)); // x.AddAllTypesOf(typeof(INotificationHandler<>)); // x.AddAllTypesOf(typeof(IAsyncNotificationHandler<>)); // }); // init.Policies.SetAllProperties(x => x.OfType<Application.IMediator>()); // //init.Policies.FillAllPropertiesOfType<Sogeti.Capstone.Web.Application.IMediator>().Use<Sogeti.Capstone.Web.Application.Mediator>(); //}); var container = new Container(init => { init.Scan(scanner => { scanner.AssemblyContainingType(typeof(IAsyncRequestHandler <,>)); scanner.AssemblyContainingType(typeof(IAsyncRequest <>)); scanner.LookForRegistries(); scanner.Assembly("Sogeti.Capstone.Domain"); scanner.Assembly("Sogeti.Capstone.Core"); scanner.WithDefaultConventions(); scanner.TheCallingAssembly(); scanner.AddAllTypesOf(typeof(IAsyncRequest <>)); scanner.AddAllTypesOf(typeof(IAsyncRequestHandler <,>)); scanner.AddAllTypesOf(typeof(INotificationHandler <>)); scanner.AddAllTypesOf(typeof(IAsyncNotificationHandler <>)); }); init.Policies.SetAllProperties(x => x.OfType <Sogeti.Capstone.Core.IMediator>()); }); //var controllerFactory = new StructureMapControllerFactory(ObjectFactory.Container); var controllerFactory = new StructureMapControllerFactory(container); ControllerBuilder.Current.SetControllerFactory(controllerFactory); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); StructureMapConfiguration.Configure(); var controllerFactory = new StructureMapControllerFactory(ObjectFactory.Container); ControllerBuilder.Current.SetControllerFactory(controllerFactory); }
public void ShouldReturnTheController() { var requestContext = new RequestContext(MvcMockHelpers.DynamicHttpContextBase(), new RouteData()); IControllerFactory factory = new StructureMapControllerFactory(); factory.InitializeWithControllerTypes(typeof(StructureMapSimpleController), typeof(StructureMapDependencyController)); IController controller = factory.CreateController(requestContext, "StructureMapSimple"); Assert.That(controller, Is.Not.Null); Assert.That(controller, Is.AssignableFrom(typeof(StructureMapSimpleController))); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); StructureMapConfiguration.Initialize(); var controllerFactory = new StructureMapControllerFactory(ObjectFactory.Container); ControllerBuilder.Current.SetControllerFactory(controllerFactory); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new NestedContainerViewEngine()); }