Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            // Get the settings from the web.config
            ConfigReaderWriter configReader = new FullTrustConfigReaderWriter("");
            ApplicationSettings applicationSettings = configReader.GetApplicationSettings();

            // Configure StructureMap dependencies
            var iocSetup = new DependencyManager(applicationSettings);
            iocSetup.Configure();
            iocSetup.ConfigureMvc();

            // Logging
            Log.ConfigureLogging(applicationSettings);

            // Filters
            GlobalFilters.Filters.Add(new HandleErrorAttribute());

            // Areas are used for:
            // - Site settings (for a cleaner view structure)
            // This should be called before the other routes, for some reason.
            AreaRegistration.RegisterAllAreas();

            // Register routes and JS/CSS bundles
            Routing.RegisterApi(GlobalConfiguration.Configuration);
            Routing.Register(RouteTable.Routes);

            // Custom view engine registration (to add directory search paths for Theme views)
            ExtendedRazorViewEngine.Register();

            app.UseWebApi(new HttpConfiguration());

            Log.Information("Application started");
        }
Exemplo n.º 2
0
        public void RegisterMvcFactoriesAndRouteHandlers_Requires_Run_First()
        {
            // Arrange
            DependencyManager container = new DependencyManager(new ApplicationSettings());

            // Act
            container.ConfigureMvc();

            // Assert
        }
Exemplo n.º 3
0
        public void RegisterMvcFactoriesAndRouteHandlers_Should_Register_Instances()
        {
            // Arrange
            RouteTable.Routes.Clear();
            DependencyManager iocSetup = new DependencyManager(new ApplicationSettings());

            // Act
            iocSetup.Configure();
            iocSetup.ConfigureMvc();

            // Assert
            Assert.That(RouteTable.Routes.Count, Is.EqualTo(1));
            Assert.That(((Route)RouteTable.Routes[0]).RouteHandler, Is.TypeOf<AttachmentRouteHandler>());
            Assert.True(ModelBinders.Binders.ContainsKey(typeof(SettingsViewModel)));
            Assert.True(ModelBinders.Binders.ContainsKey(typeof(UserViewModel)));
        }