public void AbsoluteRoute_SchemeChange(string requestScheme, string routeScheme, string routeDomain)
        {
            // Arrange
            var variables = new NameValueCollection();

            variables.Add("X_FORWARDED_PROTO", requestScheme);
            m_mockHttpContext.Setup(context => context.Request.ServerVariables).Returns(variables);
            var headers = new NameValueCollection();

            headers.Add("Host", "example.org");
            m_mockHttpContext.Setup(context => context.Request.Headers).Returns(headers);
            var defaults = new RouteValueDictionary();

            defaults.Add("domain", routeDomain);
            defaults.Add("scheme", routeScheme);
            var route     = new Route("index.html", defaults, new StopRoutingHandler());
            var routeData = new RouteData();
            var routes    = new RouteCollection();

            routes.Add("x", route);
            var helper = new UrlHelper(new RequestContext(m_mockHttpContext.Object, routeData), routes);

            // Act
            var result = UrlHelperExtensions.AbsoluteRouteUrl(helper, m_mockHttpContext.Object, "x", null);

            // Assert
            Assert.Equal(routeScheme + "://example.org/index.html", result);
        }
        public void AbsoluteRouteUrl_Unspecified_Route()
        {
            // Arrange
            var routeData = new RouteData();
            var routes    = new RouteCollection();
            var helper    = new UrlHelper(new RequestContext(m_mockHttpContext.Object, routeData), routes);

            // Act
            Assert.Throws <ArgumentException>(()
                                              => UrlHelperExtensions.AbsoluteRouteUrl(helper, m_mockHttpContext.Object, "x", null));

            // Assert
        }
        public void AbsoluteRouteUrl_Scheme_NotSpecified()
        {
            // Arrange
            var defaults  = new RouteValueDictionary();
            var route     = new Route("index.html", defaults, new StopRoutingHandler());
            var routeData = new RouteData();
            var routes    = new RouteCollection();

            routes.Add("x", route);
            var helper = new UrlHelper(new RequestContext(m_mockHttpContext.Object, routeData), routes);

            // Act
            var result = UrlHelperExtensions.AbsoluteRouteUrl(helper, m_mockHttpContext.Object, "x", null);

            // Assert
            Assert.Equal("/index.html", result);
        }
        public void AbsoluteRouteUrl_Scheme_Match(string routeScheme)
        {
            // Arrange
            var variables = new NameValueCollection();

            variables.Add("X_FORWARDED_PROTO", "https");
            m_mockHttpContext.Setup(context => context.Request.ServerVariables).Returns(variables);
            var defaults = new RouteValueDictionary();

            defaults.Add("scheme", routeScheme);
            var route     = new Route("index.html", defaults, new StopRoutingHandler());
            var routeData = new RouteData();
            var routes    = new RouteCollection();

            routes.Add("x", route);
            var helper = new UrlHelper(new RequestContext(m_mockHttpContext.Object, routeData), routes);

            // Act
            var result = UrlHelperExtensions.AbsoluteRouteUrl(helper, m_mockHttpContext.Object, "x", null);

            // Assert
            Assert.Equal("/index.html", result);
        }
        public void AbsoluteRouteUrl_Domain_Match(string routeDomain)
        {
            // Arrange
            var headers = new NameValueCollection();

            headers.Add("Host", "example.org");
            m_mockHttpContext.Setup(context => context.Request.Headers).Returns(headers);
            var defaults = new RouteValueDictionary();

            defaults.Add("domain", routeDomain);
            var route     = new Route("index.html", defaults, new StopRoutingHandler());
            var routeData = new RouteData();
            var routes    = new RouteCollection();

            routes.Add("x", route);
            var helper = new UrlHelper(new RequestContext(m_mockHttpContext.Object, routeData), routes);

            // Act
            var result = UrlHelperExtensions.AbsoluteRouteUrl(helper, m_mockHttpContext.Object, "x", null);

            // Assert
            Assert.Equal("/index.html", result);
        }