Exemple #1
0
        public void FromRouteSetsParameterName()
        {
            Expression <Func <TestController, string> > expression = c => c.TestMethod(From.Route <string>("somename"));

            var methodCall = RouteHelper.GetInnerMethodCallExpression(expression);

            var routeParameters = RouteHelper.GetRouteParameters(methodCall);

            var routeParameter = Assert.Single(routeParameters);

            Assert.Equal("somename", routeParameter.declaration.ModelName);
        }
Exemple #2
0
        public void FromFormSetsParameterNameWithoutOverride()
        {
            Expression <Func <TestController, string> > expression = c => c.TestMethod(From.Form <string>());

            var methodCall = RouteHelper.GetInnerMethodCallExpression(expression);

            var routeParameters = RouteHelper.GetRouteParameters(methodCall);

            var routeParameter = Assert.Single(routeParameters);

            Assert.Null(routeParameter.declaration.ModelName);
        }
Exemple #3
0
        public void GetActionArguments_Empty()
        {
            var expression = RouteHelper.GetInnerMethodCallExpression <TestController, string>(
                c => c.TestMethod(From.Route <string>()));

            var parameters = new[] { new ParameterDescriptor {
                                         BindingInfo = new BindingInfo()
                                     } };
            var arguments = RouteHelper.GetActionArguments(parameters, expression);

            Assert.Empty(arguments);
        }
Exemple #4
0
        public void GetActionArguments_Constant()
        {
            var expression = RouteHelper.GetInnerMethodCallExpression <TestController, string>(
                c => c.TestMethod("value"));

            var parameters = new[] { new ParameterDescriptor {
                                         BindingInfo = new BindingInfo(), Name = "parameter"
                                     } };
            var arguments = RouteHelper.GetActionArguments(parameters, expression);

            var(key, value) = Assert.Single(arguments);

            Assert.Equal("parameter", key);
            Assert.Equal("value", value);
        }