public void BoolRouteConstraint(object parameterValue, bool expected)
        {
            var constraint = new BoolRouteConstraint();
            var actual     = TestValue(constraint, parameterValue);

            Assert.Equal(expected, actual);
        }
Esempio n. 2
0
        public void BoolRouteConstraint(object parameterValue, bool expected)
        {
            // Arrange
            var constraint = new BoolRouteConstraint();

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 3
0
        private static IHttpRouteConstraint ConstraintForTypename(string typename, bool isOptional)
        {
            /* List of all route constraints:
             * https://msdn.microsoft.com/en-us/library/system.web.http.routing.constraints(v=vs.118).aspx
             */

            IHttpRouteConstraint constraint = null;

            switch (typename)
            {
            case "bool":
            case "boolean":
                constraint = new BoolRouteConstraint();
                break;

            case "int":
                constraint = new IntRouteConstraint();
                break;

            case "long":
                constraint = new LongRouteConstraint();
                break;

            case "float":
                constraint = new FloatRouteConstraint();
                break;

            case "double":
                constraint = new DoubleRouteConstraint();
                break;

            case "string":
                constraint = new AlphaRouteConstraint();
                break;
            }

            return(isOptional ? new OptionalRouteConstraint(constraint) : constraint);
        }