public void SetRouteConstraint_InitializesParameters(bool excluded)
        {
            var constraint = new SetRouteConstraint <string>(this.testSet, excluded);

            Assert.Equal(excluded, constraint.Excluded);
            Assert.Same(this.testSet, constraint.Set);
        }
        public void Match_FindsMatches(string parameterName, IDictionary <string, object> values, bool excluded, bool match)
        {
            // Arrange
            var constraint = new SetRouteConstraint <string>(this.testSet, matchOnExcluded: excluded);

            // Act
            var result = constraint.Match(request: null, route: null, parameterName: parameterName, values: values, routeDirection: HttpRouteDirection.UriResolution);

            // Assert
            Assert.Equal(match, result);
        }
コード例 #3
0
        private static void MapApiControllers(HttpConfiguration config)
        {
            HashSet <string>            tableControllerNames    = config.GetMobileAppControllerNames();
            SetRouteConstraint <string> apiControllerConstraint = new SetRouteConstraint <string>(tableControllerNames, matchOnExcluded: false);

            HttpRouteCollectionExtensions.MapHttpRoute(
                config.Routes,
                name: RouteNames.Apis,
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional },
                constraints: new { controller = apiControllerConstraint });
        }