Example #1
0
        public void ControllersCanBeExposedViaAttribute()
        {
            var config      = new Mock <IConfiguration>();
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["HelloExposed"]);

            Assert.IsTrue(result);
        }
Example #2
0
        public void ControllersCanBeHiddenViaAttribute()
        {
            var config      = new Mock <IRouteJsConfiguration>();
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["HelloHidden"]);

            Assert.IsFalse(result);
        }
        public void DefaultRouteIsHiddenIfControllerIsHiddenByDefault()
        {
            var config = new Mock <IRouteJsConfiguration>();

            config.Setup(x => x.ExposeAllRoutes).Returns(false);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var areaResult = routeFilter.AllowRoute(_routes["UndecoratedArea_default"]);

            Assert.IsFalse(areaResult);
        }
        public void RouteCanBeExposedByDefault()
        {
            var config = new Mock <IRouteJsConfiguration>();

            config.Setup(x => x.ExposeAllRoutes).Returns(true);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var areaResult = routeFilter.AllowRoute(_routes["UndecoratedArea_Hello"]);

            Assert.IsTrue(areaResult);
        }
Example #5
0
        public void IgnoredRoutesDoNotThrowAnException()
        {
            var config = new Mock <IConfiguration>();

            var routeCollection = new RouteCollection();

            routeCollection.Ignore("IgnoreMe");
            var routeFilter = new MvcRouteFilter(config.Object, routeCollection);

            Assert.DoesNotThrow(() => routeFilter.AllowRoute(routeCollection[0]));
        }
Example #6
0
        public void ExposedControllersAreExposedWhenRoutesAreHiddenByDefault()
        {
            var config = new Mock <IConfiguration>();

            config.Setup(x => x.ExposeAllRoutes).Returns(false);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["HelloExposed"]);

            Assert.IsTrue(result);
        }
Example #7
0
        public void RoutesCanBeHiddenByDefault()
        {
            var config = new Mock <IConfiguration>();

            config.Setup(x => x.ExposeAllRoutes).Returns(false);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["Hello"]);

            Assert.IsFalse(result);
        }
Example #8
0
        public void HiddenControllersAreHiddenWhenRoutesAreExposedByDefault()
        {
            var config = new Mock <IRouteJsConfiguration>();

            config.Setup(x => x.ExposeAllRoutes).Returns(true);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["HelloHidden"]);

            Assert.IsFalse(result);
        }
        public void RouteInAreaCanBeExposed()
        {
            var config      = new Mock <IRouteJsConfiguration>();
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var areaResult = routeFilter.AllowRoute(_routes["ExposedArea_Hello"]);

            Assert.IsTrue(areaResult, "Controller-specific route");

            var defaultResult = routeFilter.AllowRoute(_routes["ExposedArea_default"]);

            Assert.IsTrue(defaultResult, "Default route");
        }
Example #10
0
        public void RouteInAreaCanBeHidden()
        {
            var config      = new Mock <IConfiguration>();
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var areaResult = routeFilter.AllowRoute(_routes["HiddenArea_Hello"]);

            Assert.IsFalse(areaResult, "Controller-specific route");

            var defaultResult = routeFilter.AllowRoute(_routes["HiddenArea_Hello"]);

            Assert.IsFalse(defaultResult, "Default route");
        }
        public void ExposedAreaIsExposedWhenRoutesAreHiddenByDefault()
        {
            var config = new Mock <IRouteJsConfiguration>();

            config.Setup(x => x.ExposeAllRoutes).Returns(false);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var areaResult = routeFilter.AllowRoute(_routes["ExposedArea_Hello"]);

            Assert.IsTrue(areaResult, "Controller-specific route");

            var defaultResult = routeFilter.AllowRoute(_routes["ExposedArea_default"]);

            Assert.IsTrue(defaultResult, "Default route");
        }
Example #12
0
        public void RoutesWithNoDataTokensDoNotThrowAnException()
        {
            var config = new Mock <IConfiguration>();

            var routeCollection = new RouteCollection
            {
                new Route("foo", null)
                {
                    Defaults   = new RouteValueDictionary(),
                    DataTokens = null
                }
            };
            var routeFilter = new MvcRouteFilter(config.Object, routeCollection);

            Assert.DoesNotThrow(() => routeFilter.AllowRoute(routeCollection[0]));
        }