public void ExactMatch_Matches()
        {
            var pattern = new PatternRoute("/a/:b/c");

            var match = pattern.Match("/a/b/c");

            Assert.That(match.Score, Is.EqualTo(201));
        }
        public void ExactMatchButWithPrefix_DoesNotMatches()
        {
            var pattern = new PatternRoute("/a/:b/c");

            var match = pattern.Match("/blah/a/b/c");

            Assert.That(match.Score, Is.EqualTo(int.MinValue));
        }
        public void SinglePatternRoute_Matches()
        {
            var routes = new RoutesCollection();
            var route = new PatternRoute("/a/:b/c");
            routes.Add(route);

            var match = routes.Match("/a/b/c");

            Assert.That(match.Route, Is.SameAs(route));
        }
        public void StaticPartsScoreHigherThanParameters()
        {
            var pattern1 = new PatternRoute("/a/:b/c");
            var pattern2 = new PatternRoute("/a/:b/:c");

            var match1 = pattern1.Match("/a/b/c");
            var match2 = pattern2.Match("/a/b/c");

            Assert.That(match1.Score, Is.GreaterThan(match2.Score));
        }
        public void TwoPatterns_MatchesTheCorrectOne()
        {
            var routes = new RoutesCollection();
            var route1 = new PatternRoute("/a/:b/c");
            var route2 = new PatternRoute("/a/:b/d");
            routes.Add(route1);
            routes.Add(route2);

            var match = routes.Match("/a/b/c");

            Assert.That(match.Route, Is.SameAs(route1));
        }
        public void TwoPatternsThatMatch_MatchesTheOneWithHigherScore()
        {
            var routes = new RoutesCollection();
            var route1 = new PatternRoute("/a/:b/c");
            var route2 = new PatternRoute("/a/:b/:c");
            routes.Add(route1);
            routes.Add(route2);

            var match = routes.Match("/a/b/c");

            Assert.That(match.Route, Is.SameAs(route1));
        }
        public void ExactAndPatternsThatMatch_MatchesTheExact()
        {
            var routes = new RoutesCollection();
            var route1 = new ExactMatchRoute("/a/b/c");
            var route2 = new PatternRoute("/a/:b/c");
            routes.Add(route1);
            routes.Add(route2);

            var match = routes.Match("/a/b/c");

            Assert.That(match.Route, Is.SameAs(route1));
        }
        public void ExactMatch_TrailingSlashDoesNotMatter()
        {
            var pattern1 = new PatternRoute("/a/:b/c");
            var pattern2 = new PatternRoute("/a/:b/c/");
            var url = "/a/b/c";

            var match1 = pattern1.Match(url);
            var match2 = pattern2.Match(url);

            Assert.That(match1.Score, Is.EqualTo(201));
            Assert.That(match2.Score, Is.EqualTo(201));
        }