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 ToRouteCollection_ReturnsCollection_WithNamedRouteFromDictionary() { const string key = "route"; var route = new Route("url", new BlankRouteHandler()); var source = new RouteSource(); source.Routes.Add(Tuple.Create(key, route)); var collection = source.ToRouteCollection(); Assert.Same(route, collection[key]); }
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()); }