Exemplo n.º 1
0
        public void ControllersCanBeHiddenViaAttribute()
        {
            var config = new Mock<IConfiguration>();
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["HelloHidden"]);
            Assert.IsFalse(result);
        }
Exemplo n.º 2
0
		public void ControllersCanBeExposedViaAttribute()
		{
			var config = new Mock<IRouteJsConfiguration>();
			var routeFilter = new MvcRouteFilter(config.Object, _routes);

			var result = routeFilter.AllowRoute(_routes["HelloExposed"]);
			Assert.IsTrue(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);
		}
Exemplo n.º 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]));
        }
Exemplo n.º 6
0
        public void HiddenControllersAreHiddenWhenRoutesAreExposedByDefault()
        {
            var config = new Mock<IConfiguration>();
            config.Setup(x => x.ExposeAllRoutes).Returns(true);
            var routeFilter = new MvcRouteFilter(config.Object, _routes);

            var result = routeFilter.AllowRoute(_routes["HelloHidden"]);
            Assert.IsFalse(result);
        }
Exemplo n.º 7
0
		public void ExposedControllersAreExposedWhenRoutesAreHiddenByDefault()
		{
			var config = new Mock<IRouteJsConfiguration>();
			config.Setup(x => x.ExposeAllRoutes).Returns(false);
			var routeFilter = new MvcRouteFilter(config.Object, _routes);

			var result = routeFilter.AllowRoute(_routes["HelloExposed"]);
			Assert.IsTrue(result);
		}
Exemplo n.º 8
0
		public void RoutesCanBeHiddenByDefault()
		{
			var config = new Mock<IRouteJsConfiguration>();
			config.Setup(x => x.ExposeAllRoutes).Returns(false);
			var routeFilter = new MvcRouteFilter(config.Object, _routes);

			var result = routeFilter.AllowRoute(_routes["Hello"]);
			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");
		}
Exemplo n.º 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");
        }
Exemplo n.º 11
0
        public void ExposedAreaIsExposedWhenRoutesAreHiddenByDefault()
        {
            var config = new Mock<IConfiguration>();
            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");
        }
Exemplo n.º 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]));
        }