Пример #1
0
        public void ShouldValidateComplexThrowsErrorOnBadNames()
        {
            var validator = new ExpressiveRouteValidator1 <CustomController>(new Regex("/public/(?<test>.*)"));

            new Action(
                () =>
            {
                validator.ValidateExpression <string>(
                    (ctrlr, ctx, cld, path) => ctrlr.ExecuteWithParams(ctx, cld, 3, path, 7));
            })
            .ShouldThrow <ArgumentException>();
        }
Пример #2
0
        public void ShouldValidateComplex()
        {
            var validator = new ExpressiveRouteValidator1 <CustomController>(new Regex("/public/(?<path>.*)"));
            var tree      = validator.ValidateExpression <string>(
                (ctrlr, ctx, cld, path) => ctrlr.ExecuteWithParams(ctx, cld, 3, path, 7));

            tree.MethodName.Should().Be("ExecuteWithParams");
            tree.Parameters.Length.Should().Be(3);
            tree.Parameters[0].As <ConstantRouteExpressionParameter>().Value.Should().Be(3);
            tree.Parameters[1].As <FunctionalRouteExpressionParameter>().Name.Should().Be("path");
            tree.Parameters[2].As <ConstantRouteExpressionParameter>().Value.Should().Be(7);
        }