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");
        }
Esempio 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");
        }
Esempio 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");
        }
Esempio 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");
        }
Esempio 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);
        }
Esempio 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");
        }