public void Should_return_a_route_if_matching_and_the_filter_returns_true() { // Given var moduleCatalog = new FakeModuleCatalog(); var routeCache = new RouteCache(moduleCatalog, new FakeModuleKeyGenerator(), A.Fake<INancyContextFactory>()); var specificResolver = new DefaultRouteResolver(moduleCatalog, this.matcher, this.moduleBuilder); var request = new FakeRequest("GET", "/notfiltered"); var context = new NancyContext {Request = request}; // When var route = specificResolver.Resolve(context, routeCache).Item1; // Then route.ShouldBeOfType(typeof (Route)); }
public void Should_return_route_whos_filter_returns_true_when_there_is_also_a_matching_route_with_a_failing_filter() { // Given var moduleCatalog = new FakeModuleCatalog(); var routeCache = new RouteCache(moduleCatalog, new FakeModuleKeyGenerator(), A.Fake<INancyContextFactory>()); var specificResolver = new DefaultRouteResolver(moduleCatalog, this.matcher, this.moduleBuilder); var request = new FakeRequest("GET", "/filt"); var context = new NancyContext {Request = request}; // When var route = specificResolver.Resolve(context, routeCache).Item1; // Then route.Description.Condition(context).ShouldBeTrue(); }
public void Should_not_return_a_route_if_matching_and_the_filter_returns_false() { // Given var moduleCatalog = new FakeModuleCatalog(); var routeCache = new RouteCache(moduleCatalog, new FakeModuleKeyGenerator(), A.Fake<INancyContextFactory>(), A.Fake<IRouteSegmentExtractor>(), this.routeDescriptionProvider, A.Fake<ICultureService>()); var specificResolver = new DefaultRouteResolver(moduleCatalog, this.matcher, this.moduleBuilder, routeCache, null); var request = new FakeRequest("GET", "/filtered"); var context = new NancyContext { Request = request }; // When var route = specificResolver.Resolve(context).Item1; // Then route.ShouldBeOfType(typeof(NotFoundRoute)); }