public void ControllersCanBeExposedViaAttribute() { var config = new Mock <IConfiguration>(); var routeFilter = new MvcRouteFilter(config.Object, _routes); var result = routeFilter.AllowRoute(_routes["HelloExposed"]); Assert.IsTrue(result); }
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); }
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])); }
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); }
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); }
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"); }
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"); }
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])); }