public static Route Map(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)
        {
            var route = routes.MapRoute(name, url, defaults, constraints, namespaces);
            route.SetRouteName(name);
            var normalized = new NormalizeRoute(route);
            routes.Remove(route);
            routes.Add(name, normalized);

            return route;
        }
        public void GetVirtualPath_WithAppendTrailingSlashForRootAndQueryString_ReturnsSingleSlash() {
            // Arrange
            var originalRoute = new Mock<RouteBase>();
            originalRoute.Setup(r => r.GetVirtualPath(null, null)).Returns(new VirtualPathData(originalRoute.Object, "/?foo=bar"));
            var normalizeRoute = new NormalizeRoute(originalRoute.Object, requireLowerCase: false, appendTrailingSlash: true);

            // Act
            var url = normalizeRoute.GetVirtualPath(null, null);

            // Assert
            Assert.Equal("/?foo=bar", url.VirtualPath);
        }
        public void GetVirtualPath_WithDefaultNormalizeRoute_ReturnsLowerCaseUrl() {
            // Arrange
            var originalRoute = new Mock<RouteBase>();
            originalRoute.Setup(r => r.GetVirtualPath(null, null)).Returns(new VirtualPathData(originalRoute.Object, "/Foo/Bar"));
            var normalizeRoute = new NormalizeRoute(originalRoute.Object);

            // Act
            var url = normalizeRoute.GetVirtualPath(null, null);

            // Assert
            Assert.Equal("/foo/bar", url.VirtualPath);
        }
        public void GetVirtualPath_WithLowerCasingFalse_ReturnsOriginalCasing() {
            // Arrange
            var originalRoute = new Mock<RouteBase>();
            originalRoute.Setup(r => r.GetVirtualPath(null, null)).Returns(new VirtualPathData(originalRoute.Object, "/Foo/Bar"));
            var normalizeRoute = new NormalizeRoute(originalRoute.Object, requireLowerCase: false, appendTrailingSlash: false);

            // Act
            var url = normalizeRoute.GetVirtualPath(null, null);

            // Assert
            Assert.Equal("/Foo/Bar", url.VirtualPath);
        }