/// <summary> /// Initializes a new instance of the <see cref="Output"/> class. /// </summary> /// <param name="routeReader">The route reader.</param> /// <param name="controllerReader">Controller action reader.</param> public Output(RouteReader routeReader, ControllerReader controllerReader, IEnumerable<IJavaScriptAddition> additions) { if (routeReader == null) throw new ArgumentNullException("reader"); this.routeReader = routeReader; this.controllerReader = controllerReader; this.additions = additions ?? Enumerable.Empty<IJavaScriptAddition>(); }
public void Ctr_CallsAllInterceptorsToDetermineAcceptance() { var source = new RouteSource(); source.Routes.Add(Tuple.Create("foo", new Route("", new BlankRouteHandler()))); var reader = new RouteReader(new[] { source }, new[] { new BlankInterceptor { ReturnValue = true }, new BlankInterceptor { ReturnValue = false }, new BlankInterceptor { ReturnValue = true } }); Assert.Empty(reader.Definitions); }
public void Ctr_DoesNotAddRoute_WhenInterceptorReturnsFalse() { var source = new RouteSource(); source.Routes.Add(Tuple.Create("foo", new Route("", new BlankRouteHandler()))); var reader = new RouteReader(new[] { source }, new[] { new BlankInterceptor { ReturnValue = false } }); Assert.Empty(reader.Definitions); }
public void Ctr_AddsRouteNameToRoute() { const string name = "name"; var source = new RouteSource(); source.Routes.Add(Tuple.Create(name, new Route("", new BlankRouteHandler()))); var reader = new RouteReader(new[] { source }, new IRouteInterceptor[0]); Assert.Same(name, reader.Definitions.First().Name); }
public void Ctr_AddsRoute_WhenInterceptorReturnsTrue() { const string pattern = "{controller}/{action}"; var source = new RouteSource(); source.Routes.Add(Tuple.Create("foo", new Route(pattern, new BlankRouteHandler()))); var reader = new RouteReader(new[] { source }, new[] { new BlankInterceptor { ReturnValue = true } }); Assert.Equal(pattern, reader.Definitions.First().UrlPattern); }
public void Ctr_AddsRoutes_FromAllSources() { var source1 = new RouteSource(); source1.Routes.Add(Tuple.Create("foo", new Route("", new BlankRouteHandler()))); var source2 = new RouteSource(); source1.Routes.Add(Tuple.Create("bar", new Route("{controller}", new BlankRouteHandler()))); var source3 = new RouteSource(); source1.Routes.Add(Tuple.Create("baz", new Route("url", new BlankRouteHandler()))); source1.Routes.Add(Tuple.Create("baz2", new Route("url2", new BlankRouteHandler()))); var reader = new RouteReader(new[] { source1, source2, source3 }, new IRouteInterceptor[0] ); Assert.Equal(4, reader.Definitions.Count()); }