public virtual async Task NotMatch_SingleParameter(string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher("/{p}");
            var(httpContext, context) = CreateContext(path);

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

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

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

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);
        }
Ejemplo n.º 3
0
        public async Task Match_HostWithPort_IncorrectHost()
        {
            // Arrange
            var endpoint = CreateEndpoint("/hello", hosts: new string[] { "contoso.com:8080", });

            var matcher = CreateMatcher(endpoint);

            var(httpContext, context) = CreateContext("/hello", "www.contoso.com:8080");

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

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);
        }
Ejemplo n.º 4
0
        public async Task Match_HostWithPort_NoHostHeader()
        {
            // Arrange
            var endpoint = CreateEndpoint("/hello", hosts: new string[] { "contoso.com:443", });

            var matcher = CreateMatcher(endpoint);

            var(httpContext, context) = CreateContext("/hello", null, "https");

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

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);
        }
        [Fact] // When one of the candidates handles all verbs, dont use a 405 endpoint
        public async Task NotMatch_ProtoMethod_WithAllMethodEndpoint_DoesNotReturn405()
        {
            // Arrange
            var endpoint1 = CreateEndpoint("/{x:int}", httpMethods: new string[] { });
            var endpoint2 = CreateEndpoint("/hello", httpMethods: new string[] { "DELETE" });

            var matcher = CreateMatcher(endpoint1, endpoint2);

            var(httpContext, context) = CreateContext("/hello", "POST");

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

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);
        }
        [Fact] // When all of the candidates handles specific verbs, use a 405 endpoint
        public async Task NotMatch_ProtoMethod_CORS_DoesNotReturn405()
        {
            // Arrange
            var endpoint1 = CreateEndpoint("/hello", httpMethods: new string[] { "GET", "PUT" }, acceptCorsPreflight: true);
            var endpoint2 = CreateEndpoint("/hello", httpMethods: new string[] { "DELETE" });

            var matcher = CreateMatcher(endpoint1, endpoint2);

            var(httpContext, context) = CreateContext("/hello", "POST", corsPreflight: true);

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

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);
        }
        public virtual async Task Quirks_CatchAllParameter(string template, string path, string[] keys, string[] values)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, context) = CreateContext(path);

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

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);

            // Need to access these to prevent a warning from the xUnit analyzer.
            // Some of these tests will match (and process the values) and some will not.
            GC.KeepAlive(keys);
            GC.KeepAlive(values);
        }