public virtual async Task Match_SingleLiteralSegment_CaseInsensitive(string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/Simple");
            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint);
        }
        [InlineData("/S\\imple", "/S\\imple")] // surrogate pair
        public virtual async Task Match_SingleLiteralSegment_PercentEncoded(string template, string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint);
        }
        public virtual async Task NotMatch_MultipleParameters(string template, string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertNotMatch(feature);
        }
        public virtual async Task Match_SingleLiteralSegment_TrailingSlash()
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/simple");
            var(httpContext, feature) = CreateContext("/simple/");

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint);
        }
        public virtual async Task Match_Sanitizies_Template(string template)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, feature) = CreateContext("/simple");

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint);
        }
        public virtual async Task Match_EmptyRoute()
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/");
            var(httpContext, feature) = CreateContext("/");

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint);
        }
예제 #7
0
        public virtual async Task Match_WierdCharacterCases(string template, string path, string[] keys, string[] values)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint, keys, values);
        }
        public virtual async Task Match_SingleParameter_TrailingSlash()
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/{p}");
            var(httpContext, feature) = CreateContext("/14/");
            var values = new RouteValueDictionary(new { p = "14", });

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint, values);
        }
        public virtual async Task Match_Constraint()
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/{p:int}");
            var(httpContext, feature) = CreateContext("/14");
            var values = new RouteValueDictionary(new { p = "14", });

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint, values);
        }
예제 #10
0
        public virtual async Task Match_ExtraDefaultValues()
        {
            // Arrange
            var endpoint = CreateEndpoint("/a/{b}/{c}", new { b = "17", c = "18", d = "19" });
            var matcher  = CreateMatcher(endpoint);

            var(httpContext, feature) = CreateContext("/a");

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint, new { b = "17", c = "18", d = "19" });
        }
        public virtual async Task Match_SingleParameter_WierdNames()
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/foo/{ }/{.!$%}/{dynamic.data}");
            var(httpContext, feature) = CreateContext("/foo/space/weirdmatch/matcherid");
            var values = new RouteValueDictionary()
            {
                { " ", "space" },
                { ".!$%", "weirdmatch" },
                { "dynamic.data", "matcherid" },
            };

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, endpoint, values);
        }
예제 #12
0
        public virtual async Task Match_SelectEndpoint_BasedOnOrder(string template1, string template2)
        {
            // Arrange
            var expected = CreateEndpoint(template1, order: 0);
            var other    = CreateEndpoint(template2, order: 1);
            var path     = "/template/5";

            // Arrange
            var matcher = CreateMatcher(other, expected);

            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, expected, ignoreValues: true);
        }
예제 #13
0
        public virtual async Task Match_IntegrationTest_MultipleEndpoints(string path, string expectedTemplate)
        {
            // Arrange
            var templates = new[]
            {
                "",
                "Literal1",
                "Literal1/Literal2",
                "Literal1/Literal2/Literal3",
                "Literal1/Literal2/Literal3/{*constrainedCatchAll:int}",
                "Literal1/Literal2/Literal3/{*catchAll}",
                "{constrained1:int}",
                "{constrained1:int}/{constrained2:int}",
                "{constrained1:int}/{constrained2:int}/{constrained3:int}",
                "{constrained1:int}/{constrained2:int}/{constrained3:int}/{*constrainedCatchAll:int}",
                "{constrained1:int}/{constrained2:int}/{constrained3:int}/{*catchAll}",
                "{parameter1}",
                "{parameter1}/{parameter2}",
                "{parameter1}/{parameter2}/{parameter3}",
                "{parameter1}/{parameter2}/{parameter3}/{*constrainedCatchAll:int}",
                "{parameter1}/{parameter2}/{parameter3}/{*catchAll}",
            };

            var endpoints = templates.Select((t) => CreateEndpoint(t)).ToArray();
            var expected  = endpoints[Array.IndexOf(templates, expectedTemplate)];

            var matcher = CreateMatcher(endpoints);

            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            DispatcherAssert.AssertMatch(feature, expected, ignoreValues: true);
        }