Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TreeRouterMatcherConformanceTest.cs « Matching « UnitTests « test « Routing « Http « src - github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1ae231a324e26f717e5aa2bb220966440112bc7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Threading.Tasks;
using Xunit;

namespace Microsoft.AspNetCore.Routing.Matching
{
    public class TreeRouterMatcherConformanceTest : FullFeaturedMatcherConformanceTest
    {
        // TreeRouter doesn't support non-inline default values.
        [Fact]
        public override Task Match_NonInlineDefaultValues()
        {
            return Task.CompletedTask;
        }

        // TreeRouter doesn't support non-inline default values.
        [Fact]
        public override Task Match_ExtraDefaultValues()
        {
            return Task.CompletedTask;
        }

        // https://github.com/dotnet/aspnetcore/issues/18677
        //
        [Theory]
        [InlineData("/middleware", 1)]
        [InlineData("/middleware/test", 1)]
        [InlineData("/middleware/test1/test2", 1)]
        [InlineData("/bill/boga", 0)]
        public async Task Match_Regression_1867(string path, int endpointIndex)
        {
            var endpoints = new RouteEndpoint[]
            {
                EndpointFactory.CreateRouteEndpoint(
                    "{firstName}/{lastName}",
                    order: 0,
                    defaults: new { controller = "TestRoute", action = "Index", }),

                EndpointFactory.CreateRouteEndpoint(
                    "middleware/{**_}",
                    order: 0),
            };

            var expected = endpoints[endpointIndex];

            var matcher = CreateMatcher(endpoints);
            var httpContext = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertMatch(httpContext, expected, ignoreValues: true);
        }

        internal override Matcher CreateMatcher(params RouteEndpoint[] endpoints)
        {
            var builder = new TreeRouterMatcherBuilder();
            for (var i = 0; i < endpoints.Length; i++)
            {
                builder.AddEndpoint(endpoints[i]);
            }
            return builder.Build();
        }
    }
}