Beispiel #1
0
        public void RootMatch()
        {
            var pattern = new UrlPattern("/");

            Assert.IsTrue(pattern.Match("/") != null);
            Assert.IsTrue(pattern.Match("/test") == null);
            Assert.IsTrue(pattern.Match("/test/") == null);
        }
Beispiel #2
0
        public void NormalFill()
        {
            var pattern = new UrlPattern("/users/(name)");
            var parameters = new Dictionary<string, string>()
            {
                {"name", "mayhem"}
            };

            Assert.AreEqual("/users/mayhem", pattern.Fill(parameters));
        }
Beispiel #3
0
        public void ContinuationFill()
        {
            var pattern = new UrlPattern("/users/(name)/...");
            var parameters = new Dictionary<string, string>()
            {
                {"name", "mayhem"}
            };

            Assert.AreEqual("/users/mayhem/", pattern.Fill(parameters));
        }
Beispiel #4
0
        public void NormalMatch()
        {
            var pattern = new UrlPattern("/users/(name)");

            Assert.AreEqual(2, pattern.Segments.Count);
            Assert.AreEqual(pattern.PatternEnd, UrlPatternEnd.Normal);
            Assert.IsTrue(pattern.Segments[0] is UrlStringSegment);
            Assert.IsTrue(pattern.Segments[1] is UrlParameterSegment);

            Assert.IsTrue(pattern.Match("/users/") == null);
            Assert.IsTrue(pattern.Match("/users/mayhem") != null);
            Assert.IsTrue(pattern.Match("/users/mayhem/") == null);
            Assert.IsTrue(pattern.Match("/users/mayhem/test") == null);
            Assert.IsTrue(pattern.Match("/users/mayhem/test/") == null);
        }