protected void Application_Start()
        {
            //AreaRegistration.RegisterAllAreas();
            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

            adminArea.RegisterArea(adminAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

            defaultArea.RegisterArea(defaultAreaContext);

            //WebApiConfig.Register(GlobalConfiguration.Configuration);
            //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            /*AreaRegistration.RegisterAllAreas();
             *
             * WebApiConfig.Register(GlobalConfiguration.Configuration);
             * FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
             * RouteConfig.RegisterRoutes(RouteTable.Routes);
             * BundleConfig.RegisterBundles(BundleTable.Bundles);*/
        }
Exemple #2
0
        private void TestIncomingRoute(string url, Dictionary <string, string> route)
        {
            RouteCollection routes       = new RouteCollection();
            var             adminArea    = new AdminAreaRegistration();
            var             businessArea = new BusinessAreaRegistration();

            adminArea.RegisterArea(new AreaRegistrationContext(adminArea.AreaName, routes));
            businessArea.RegisterArea(new AreaRegistrationContext(businessArea.AreaName, routes));
            MvcApplication.RegisterRoutes(routes);

            var httpContext = GetMockHttpContext(url);

            var routeData = routes.GetRouteData(httpContext.Object);

            Assert.IsNotNull(routeData, "route data should not be null");
            Assert.IsNotNull(routeData.Route, "route should not be null");

            foreach (var key in route.Keys)
            {
                if (route[key] == null)
                {
                    Assert.IsNull(routeData.Values[key]);
                }
                else
                {
                    Assert.AreEqual(route[key], routeData.Values[key], "unexptected value for {0}", key);
                }
            }
        }
Exemple #3
0
        protected void Application_Start()
        {
            //AreaRegistration.RegisterAllAreas();


            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

            adminArea.RegisterArea(adminAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

            defaultArea.RegisterArea(defaultAreaContext);

            //WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            VetDBDataContext data = new VetDBDataContext();

            try
            {
                data.CreateDatabase();
            }
            catch
            {
            }
        }
        public void RouteCollectionSetup()
        {
            var areaReg = new AdminAreaRegistration();
            var areaContext = new AreaRegistrationContext(areaReg.AreaName, RouteTable.Routes);
            areaReg.RegisterArea(areaContext);

            RouteConfig.RegisterRoutes(RouteTable.Routes);

            this.routeCollection = RouteTable.Routes;
        }
Exemple #5
0
        public void HaveAreaNameProperty_WithTheCorrectName()
        {
            // Arrange
            string correctAreaName = "Admin";

            AdminAreaRegistration registration = new AdminAreaRegistration();

            // Act, Assert
            Assert.AreSame(registration.AreaName, correctAreaName);
        }
Exemple #6
0
        public void RouteCollectionSetup()
        {
            var area2Reg     = new AdminAreaRegistration();
            var area2Context = new AreaRegistrationContext(area2Reg.AreaName, RouteTable.Routes);

            area2Reg.RegisterArea(area2Context);

            RouteConfig.RegisterRoutes(RouteTable.Routes);

            this.routeCollection = RouteTable.Routes;
        }
        public void SetLowercaseUrlsToTrue_WhenRegistrationContextIsProvided()
        {
            // Arrange
            AdminAreaRegistration   registration = new AdminAreaRegistration();
            AreaRegistrationContext context      = new AreaRegistrationContext(
                registration.AreaName,
                new RouteCollection());

            // Act
            registration.RegisterArea(context);

            // Assert
            Assert.That(context.Routes.LowercaseUrls, Is.EqualTo(true));
        }
        public RoutingTests()
        {
            Routes = new RouteCollection();

            var httpContextBase = Substitute.For <HttpContextBase>();

            httpContextBase.Server.MapPath(Arg.Any <string>()).Returns(@"c:\folderthatdoesntexist");
            var adminAreaRegistration   = new AdminAreaRegistration(new Lazy <HttpContextBase>(() => httpContextBase));
            var areaRegistrationContext = new AreaRegistrationContext(adminAreaRegistration.AreaName, Routes);

            adminAreaRegistration.RegisterArea(areaRegistrationContext);

            RouteConfig.RegisterRoutes(Routes);
        }
Exemple #9
0
        private void TestRouteFail(string url)
        {
            var routes = new RouteCollection();
            var adminAreaRegistration = new AdminAreaRegistration();
            var registrationContext   = new AreaRegistrationContext("Admin", routes);

            adminAreaRegistration.RegisterArea(registrationContext);
            RouteConfig.RegisterRoutes(routes);
            var httpContext = GetHttpContext(url);

            var result = routes.GetRouteData(httpContext);

            Assert.IsNull(result?.Route);
        }
Exemple #10
0
        public void TestRouteAdminUsersIndex()
        {
            const string Url = "/Admin/Users";
            const string AreaName = "Admin";

            var routeCollection = new RouteCollection();

            var areaRegistration = new AdminAreaRegistration();
            Assert.AreEqual(AreaName, areaRegistration.AreaName);
            var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routeCollection);
            areaRegistration.RegisterArea(areaRegistrationContext);

            routeCollection.ShouldMap(Url).To<UsersController>(c => c.Index());
        }
Exemple #11
0
    public static void RegisterAreas()
    {
        //
        // Admin area . . .
        var adminArea        = new AdminAreaRegistration();
        var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

        adminArea.RegisterArea(adminAreaContext);
        //
        // Default area . . .
        var defaultArea        = new DefaultAreaRegistration();
        var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

        defaultArea.RegisterArea(defaultAreaContext);
    }
Exemple #12
0
        private void TestRouteMatch(string url, Dictionary <string, string> routeValues, string httpMethod = "GET")
        {
            var routes = new RouteCollection();
            var adminAreaRegistration = new AdminAreaRegistration();
            var registrationContext   = new AreaRegistrationContext("Admin", routes);

            adminAreaRegistration.RegisterArea(registrationContext);
            RouteConfig.RegisterRoutes(routes);
            var httpContext = GetHttpContext(url, httpMethod);


            var result = routes.GetRouteData(httpContext);

            Assert.IsNotNull(result);
            Assert.IsTrue(TestIncomingRouteResult(result, routeValues));
        }
Exemple #13
0
        private string GenerateUrlFromMock(object values)
        {
            var routes       = new RouteCollection();
            var adminArea    = new AdminAreaRegistration();
            var businessArea = new BusinessAreaRegistration();

            adminArea.RegisterArea(new AreaRegistrationContext(adminArea.AreaName, routes));
            businessArea.RegisterArea(new AreaRegistrationContext(businessArea.AreaName, routes));

            MvcApplication.RegisterRoutes(routes);

            var context    = GetMockHttpContext(null);
            var reqContext = new RequestContext(context.Object, new RouteData());

            return(UrlHelper.GenerateUrl(null, null, null, new RouteValueDictionary(values), routes, reqContext, true));
        }
Exemple #14
0
        protected void Application_Start()
        {
            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

            adminArea.RegisterArea(adminAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

            defaultArea.RegisterArea(defaultAreaContext);

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Exemple #15
0
        /// <summary>
        /// Вызывается, когда первый экземпляр HttpApplication создается. Это позволяет создавать объекты доступные для всех экземпляров класса HttpApplication.
        /// </summary>
        protected void Application_Start()
        {
            _logger.Info("Application starting");

            #region AreasRegistration
            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);
            adminArea.RegisterArea(adminAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);
            defaultArea.RegisterArea(defaultAreaContext);
            #endregion

            //если сразу регистрировать все области, то сначала зарегается Default и тогда до Admin будет не достучаться
            //поэтому используем код выше
            //AreaRegistration.RegisterAllAreas();

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Database.SetInitializer <PracticeContext>(new EFDbInitializer());
            CommonMapper.Configurate();
        }
Exemple #16
0
        protected void Application_Start()
        {
            logger.Info("Application Start");

            // RegisterAllAreas() регистрирует все найденные объявления area, но она нам не подходит,
            // так как если DefaultArea зарегистрировать раньше AdminArea, то будет срабатывать маршрутизация Default,
            // а в админку мы уже не сможем попасть, поэтому исправляем
            //AreaRegistration.RegisterAllAreas();
            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

            adminArea.RegisterArea(adminAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

            defaultArea.RegisterArea(defaultAreaContext);


            //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Exemple #17
0
        protected void Application_Start()
        {
            PreStartApp.logger.Info("Application Start");

            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

            adminArea.RegisterArea(adminAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

            defaultArea.RegisterArea(defaultAreaContext);

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            mailThread = new Thread(new ThreadStart(ThreadFunc));
            mailThread.Start();

            DefaultModelBinder.ResourceClassKey = "Messages";
        }
        protected void Application_Start()
        {
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            GlobalConfiguration.Configure(WebApiConfig.Register);

            var adminArea        = new AdminAreaRegistration();
            var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes);

            adminArea.RegisterArea(adminAreaContext);

            var mapArea        = new MapAreaRegistration();
            var mapAreaContext = new AreaRegistrationContext(mapArea.AreaName, RouteTable.Routes);

            mapArea.RegisterArea(mapAreaContext);

            var defaultArea        = new DefaultAreaRegistration();
            var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes);

            defaultArea.RegisterArea(defaultAreaContext);

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Рассылка актуальной версии карты
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    MapHub.BroadcastSystems();
                    Thread.Sleep(10000);
                }
            });
        }
Exemple #19
0
        public void AdminAreaTest()
        {
            var adminArea = new AdminAreaRegistration();

            Assert.That(adminArea.AreaName == "Admin");
        }
Exemple #20
0
 public void Setup()
 {
     AdminAreaRegistration.CreateMappings();
 }