Esempio n. 1
0
        public void should_not_match(string path, string method, string pattern)
        {
            var request = new StubHttpRequest {
                Method = method, Path = path
            };

            request.IsFor("GET", pattern).ShouldBe(false);
        }
Esempio n. 2
0
        public void should_not_match(string path, string method, string pattern)
        {
            var request = new StubHttpRequest {
                Method = method, Path = path
            };

            var result = request.IsFor("GET", pattern, out var tokens);

            Assert.False(result);
            Assert.Null(tokens);
        }
        public void should_not_match(string path, string method, string pattern)
        {
            var request = new StubHttpRequest {
                Method = method, Path = path
            };

            IDictionary <string, string> tokens;
            PathString remainder;
            var        result = request.IsFor("GET", pattern, out tokens, out remainder);

            Assert.False(result);
            Assert.Null(tokens);
        }
Esempio n. 4
0
        public void should_match(string path, string method, string pattern, string[] expectedTokenKeys, string[] expectedTokenValues)
        {
            var request = new StubHttpRequest {
                Method = method, Path = path
            };

            var result = request.IsFor("GET", pattern, out var tokens);

            Assert.True(result);
            Assert.AreEqual(expectedTokenKeys.Length, tokens.Count);

            for (var i = 0; i < expectedTokenKeys.Length; i++)
            {
                Assert.AreEqual(expectedTokenValues[i], tokens[expectedTokenKeys[i]]);
            }
        }
        public void should_match(string urlEncodedPath, string method, string pattern, string[] expectedTokenKeys, string[] expectedTokenValues, string expectedRemainder)
        {
            // PathString seemingly automatically encodes the string even if it's already encoded
            var request = new StubHttpRequest {
                Method = method, Path = WebUtility.UrlDecode(urlEncodedPath)
            };

            IDictionary <string, string> tokens;
            PathString remainder;
            var        result = request.IsFor(method, pattern, out tokens, out remainder);

            result.ShouldBe(true);
            tokens.Count.ShouldBe(expectedTokenKeys.Length);

            for (var i = 0; i < expectedTokenKeys.Length; i++)
            {
                Assert.AreEqual(expectedTokenValues[i], tokens[expectedTokenKeys[i]]);
            }

            remainder.ToString().ShouldBe(expectedRemainder);
        }