예제 #1
0
 public Route(string routeName, string expression, string controllerName = null, string pageTitle = null, string sectionName = null)
 {
     RouteName       = routeName;
     routeExpression = expression;
     ControllerName  = controllerName;
     PageTitle       = pageTitle;
     SectionName     = sectionName;
     Tiles           = new Collection <TileDefinition>();
     evaluator       = RouteParser.GenerateRegEx(routeExpression);
 }
예제 #2
0
        public void CaptureTwosegments()
        {
            const string routeDefinition = "/documents/{category,2}/support";
            const string expected        = @"^/documents(?:/(?<category>[\w\d\s\-\+'_%,]+)){2}/support/?$";

            Regex actual = RouteParser.GenerateRegEx(routeDefinition);

            AssertStringsSame(expected, actual.ToString());

            Match matchTwo = actual.Match("/documents/cantilever/fixed/support");

            Assert.IsTrue(matchTwo.Success);
            Assert.AreEqual(2, matchTwo.Groups.Count, "Expected 2 groups.");
            Assert.AreEqual(2, matchTwo.Groups[1].Captures.Count, "Expected 2 captures.");
            Assert.AreEqual("cantilever", matchTwo.Groups["category"].Captures[0].Value, "Expected cantilever for first capture.");
            Assert.AreEqual("fixed", matchTwo.Groups["category"].Captures[1].Value, "Expected fixed for second capture.");
        }