public void route_without_strategies_not_routed()
        {
            var route = new CanonicalizeRoute();
            var inputUrl = new Uri("http://example.com");
            var context = CreateFakeHttpContext(inputUrl);

            var routeData = route.GetRouteData(context);

            Assert.Null(routeData);
        }
        public void post_request_not_routed()
        {
            var filter = new Mock<IUrlStrategy>();
            var inputUri = new UriBuilder("http://example.com");
            filter.Setup(x => x.Apply(inputUri)).Callback<UriBuilder>(x => x.Scheme = "https");

            var route = new CanonicalizeRoute();
            route.Strategies.Add(filter.Object);

            var context = CreateFakeHttpContext(inputUri.Uri, "POST");
            var routeData = route.GetRouteData(context);

            Assert.Null(routeData);
        }
        public void route_with_nonchanging_strategy_not_routed()
        {
            var filter = new Mock<IUrlStrategy>();
            var inputUri = new UriBuilder("http://example.com");
            filter.Setup(x => x.Apply(inputUri));

            var route = new CanonicalizeRoute();
            route.Strategies.Add(filter.Object);

            var context = CreateFakeHttpContext(inputUri.Uri);

            var routeData = route.GetRouteData(context);

            Assert.Null(routeData);
        }
        public void route_strategies_are_invoked()
        {
            var filter = new Mock<IUrlStrategy>();
            var inputUri = new UriBuilder("http://example.com");
            filter.Setup(x => x.Apply(inputUri)).Verifiable();

            var route = new CanonicalizeRoute();
            route.Strategies.Add(filter.Object);

            var context = CreateFakeHttpContext(inputUri.Uri);

            route.GetRouteData(context);

            filter.Verify();
        }
        public void route_with_changing_strategy_routed()
        {
            var filter = new Mock<IUrlStrategy>();
            var inputUri = new UriBuilder("http://example.com");
            filter.Setup(x => x.Apply(inputUri)).Callback<UriBuilder>(x => x.Scheme = "https");

            var route = new CanonicalizeRoute();
            route.Strategies.Add(filter.Object);

            var context = CreateFakeHttpContext(inputUri.Uri);
            var routeData = route.GetRouteData(context);

            Assert.NotNull(routeData);
            Assert.NotNull(routeData.RouteHandler);
            Assert.IsInstanceOf<RedirectHandler>(routeData.RouteHandler);
        }
 /// <summary>
 /// Initializes a <see cref="CanonicalizeRouteBuilder"/> for configuration of a specific <see cref="CanonicalizeRoute"/>.
 /// </summary>
 /// <param name="route">The route to be configured using the fluent API.</param>
 public CanonicalizeRouteBuilder(CanonicalizeRoute route)
 {
     _route = route;
 }