public void Should_return_default_url_when_override_not_specified()
        {
            var actionMethod = Type <Handler> .Expression(x => x.NoOverride()).ToActionMethod();

            var urls = new DefaultUrlConvention()
                       .GetUrls(new UrlContext(null, null, actionMethod,
                                               null, new []  { "some", "url" },
                                               null, null, null, null, null));

            urls.ShouldOnlyContain("some/url");
        }
        public void Should_return_overriden_urls()
        {
            var actionMethod = Type <Handler> .Method(x => x.Override()).ToActionMethod <Handler>();

            var urls = new DefaultUrlConvention()
                       .GetUrls(new UrlContext(null, null, actionMethod,
                                               null, new[] { "some", "url" },
                                               null, null, null, null, null));

            urls.ShouldOnlyContain("url1", "url2");
        }
Ejemplo n.º 3
0
        public void Should_return_attribute_url_aliases()
        {
            var actionMethod = ActionMethod.From <AliasHandler>(x => x.Get());
            var urls         = new DefaultUrlConvention(_configuration, null)
                               .GetUrls(new UrlContext(actionMethod,
                                                       null, new List <UrlSegment>
            {
                new UrlSegment("some"),
                new UrlSegment("url")
            }, null, null, null, null));

            urls.ShouldOnlyContain("Unit/Routing/some/url", "url1", "url2");
        }
Ejemplo n.º 4
0
        public void Should_return_default_url_when_override_not_specified()
        {
            var actionMethod = ActionMethod.From <Handler>(x => x.NoOverride());
            var urls         = new DefaultUrlConvention(_configuration, null)
                               .GetUrls(new UrlContext(actionMethod,
                                                       null, new List <UrlSegment>
            {
                new UrlSegment("some"),
                new UrlSegment("url")
            },
                                                       null, null, null, null));

            urls.ShouldOnlyContain("Unit/Routing/some/url");
        }
Ejemplo n.º 5
0
        public void Should_return_overriden_urls()
        {
            var actionMethod = ActionMethod.From <Handler>(x => x.Override());
            var urls         = new DefaultUrlConvention(_configuration, null)
                               .GetUrls(new UrlContext(actionMethod,
                                                       null, new List <UrlSegment>
            {
                new UrlSegment("some"),
                new UrlSegment("url")
            },
                                                       null, null, null, null));

            urls.ShouldOnlyContain("url1", "url2");
        }
Ejemplo n.º 6
0
        public void Should_add_url_prefix(string prefix, string expected)
        {
            var actionMethod = ActionMethod.From <Handler>(x => x.NoOverride());

            _configuration.UrlPrefix = prefix;
            var urls = new DefaultUrlConvention(_configuration, null)
                       .GetUrls(new UrlContext(actionMethod,
                                               null, new List <UrlSegment>
            {
                new UrlSegment("some"),
                new UrlSegment("url")
            },
                                               null, null, null, null));

            urls.ShouldOnlyContain(expected);
        }
Ejemplo n.º 7
0
        public void Should_return_conventional_url_aliases()
        {
            var actionMethod = ActionMethod.From <AliasHandler>(x => x.Post());

            _configuration.UrlAliases.Add(x => $"{x.ActionMethod.MethodDescriptor.Name}/url1/{x.MethodSegments.ToUrl()}");
            _configuration.UrlAliases.Add(x => $"{x.ActionMethod.MethodDescriptor.Name}/url2/{x.MethodSegments.ToUrl()}");
            var urls = new DefaultUrlConvention(_configuration, null)
                       .GetUrls(new UrlContext(actionMethod,
                                               null, new List <UrlSegment>
            {
                new UrlSegment("some"),
                new UrlSegment("url")
            },
                                               null, null, null, null));

            urls.ShouldOnlyContain("Unit/Routing/some/url",
                                   "Post/url1/some/url", "Post/url2/some/url");
        }
Ejemplo n.º 8
0
        public List <ActionDescriptor> GetActions()
        {
            var configuration      = new Configuration();
            var actionMethodSource = new DefaultActionMethodSource(configuration, _typeCache);
            var urlConvention      = new DefaultUrlConvention(configuration, _httpConfiguration);
            var routeConvention    = new DefaultRouteConvention(configuration,
                                                                _httpConfiguration, urlConvention.AsList <IUrlConvention>(), _constraintBuilder);

            new ConfigurationDsl(configuration, _httpConfiguration)
            .IncludeTypeAssembly <DiagnosticsActionSource>()
            .OnlyIncludeHandlersUnder <DiagnosticsActionSource>()
            .ConfigureNamespaceUrlMapping(x => x.Clear()
                                          .MapNamespaceAfter <DiagnosticsActionSource>())
            .WithUrlPrefix(_configuration.DiagnosticsUrl.Trim('/'))
            .ConfigureUrlConventions(x => x.Clear().Append(urlConvention))
            .ConfigureActionMethodSources(x => x.Clear().Append(actionMethodSource))
            .ConfigureRouteConventions(x => x.Clear().Append(routeConvention));

            return(new DefaultActionSource(configuration, _httpConfiguration,
                                           actionMethodSource.AsList(), routeConvention.AsList(),
                                           _actionDescriptorFactory).GetActions());
        }