Inheritance: UCosmic.Www.Mvc.Controllers.MvcRoute
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
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);
            }
Exemplo n.º 4
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);
            }
Exemplo n.º 5
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);
                    }
                }
            }
Exemplo n.º 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);
                    }
                }
            }