Inheritance: UCosmic.Www.Mvc.Controllers.MvcRoute
示例#1
0
 public void InBoundUrl_WithAnyMethod_IsRouted()
 {
     Expression<Func<ErrorsController, ActionResult>> action =
         controller => controller.NotFound();
     var url = new ErrorsRouter.NotFoundRoute().Url.ToAppRelativeUrl();
     url.WithAnyMethod().ShouldMapTo(action);
 }
示例#2
0
 public void OutBoundUrl_IsRouted()
 {
     Expression<Func<ErrorsController, ActionResult>> action =
         controller => controller.NotFound();
     var url = new ErrorsRouter.NotFoundRoute().Url.ToAppRelativeUrl();
     OutBoundRoute.Of(action).InArea(Area).AppRelativeUrl().ShouldEqual(url);
 }
            public void InBoundUrl_WithAnyMethod_IsRouted()
            {
                Expression <Func <ErrorsController, ActionResult> > action =
                    controller => controller.NotFound();
                var url = new ErrorsRouter.NotFoundRoute().Url.ToAppRelativeUrl();

                url.WithAnyMethod().ShouldMapTo(action);
            }
            public void OutBoundUrl_IsRouted()
            {
                Expression <Func <ErrorsController, ActionResult> > action =
                    controller => controller.NotFound();
                var url = new ErrorsRouter.NotFoundRoute().Url.ToAppRelativeUrl();

                OutBoundRoute.Of(action).InArea(Area).AppRelativeUrl().ShouldEqual(url);
            }
            public void InBoundUrls_AreRoutedTo_NotFound()
            {
                Expression <Func <ErrorsController, ActionResult> > action =
                    controller => controller.NotFound();
                var routeUrls = new ErrorsRouter.NotFoundRoute().AlternateUrls;

                const string catchallParam = "*catchall";
                const string catchallValue = "any";
                const string prefixParam   = "prefix";
                const string prefixValue   = "any";

                foreach (var routeUrl in routeUrls)
                {
                    if (routeUrl.Contains(catchallParam))
                    {
                        var urlFormat       = routeUrl.Replace(catchallParam, "0").ToAppRelativeUrl();
                        var urlWithCatchall = string.Format(urlFormat, catchallValue);
                        urlWithCatchall.WithAnyMethod().ShouldMapTo(action);

                        var urlWithTrailingSlash = string.Format(urlFormat, string.Empty);
                        urlWithTrailingSlash.WithAnyMethod().ShouldMapTo(action);

                        var urlWithoutTrailingSlash = urlWithTrailingSlash.WithoutTrailingSlash();
                        urlWithoutTrailingSlash.WithAnyMethod().ShouldMapTo(action);
                    }
                    else if (routeUrl.Contains(prefixParam))
                    {
                        var urlFormat = routeUrl.Replace(prefixParam, "0").ToAppRelativeUrl();
                        var url       = string.Format(urlFormat, prefixValue);
                        url.WithAnyMethod().ShouldMapTo(action);
                    }
                    else
                    {
                        var url = routeUrl.ToAppRelativeUrl();
                        url.WithAnyMethod().ShouldMapTo(action);
                    }
                }
            }
示例#6
0
            public void InBoundUrls_AreRoutedTo_NotFound()
            {
                Expression<Func<ErrorsController, ActionResult>> action =
                    controller => controller.NotFound();
                var routeUrls = new ErrorsRouter.NotFoundRoute().AlternateUrls;

                const string catchallParam = "*catchall";
                const string catchallValue = "any";
                const string prefixParam = "prefix";
                const string prefixValue = "any";
                foreach (var routeUrl in routeUrls)
                {
                    if (routeUrl.Contains(catchallParam))
                    {
                        var urlFormat = routeUrl.Replace(catchallParam, "0").ToAppRelativeUrl();
                        var urlWithCatchall = string.Format(urlFormat, catchallValue);
                        urlWithCatchall.WithAnyMethod().ShouldMapTo(action);

                        var urlWithTrailingSlash = string.Format(urlFormat, string.Empty);
                        urlWithTrailingSlash.WithAnyMethod().ShouldMapTo(action);

                        var urlWithoutTrailingSlash = urlWithTrailingSlash.WithoutTrailingSlash();
                        urlWithoutTrailingSlash.WithAnyMethod().ShouldMapTo(action);
                    }
                    else if (routeUrl.Contains(prefixParam))
                    {
                        var urlFormat = routeUrl.Replace(prefixParam, "0").ToAppRelativeUrl();
                        var url = string.Format(urlFormat, prefixValue);
                        url.WithAnyMethod().ShouldMapTo(action);
                    }
                    else
                    {
                        var url = routeUrl.ToAppRelativeUrl();
                        url.WithAnyMethod().ShouldMapTo(action);
                    }
                }
            }