Пример #1
0
        /// <summary>
        /// Asserts that the API route for the url exists to the specified controller, but does not have the specified Http method.
        /// </summary>
        public static void ApiRouteDoesNotHaveMethod(HttpConfiguration config, string url, Type controllerType, HttpMethod httpMethod)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);
            var request = new HttpRequestMessage(httpMethod, absoluteUrl);
            var apiRouteGenerator = new ApiRouteGenerator(config, request);

            apiRouteGenerator.CheckControllerHasNoMethod(url, httpMethod, controllerType);
        }
Пример #2
0
        /// <summary>
        /// Asserts that an entry in the routing table is found that matches this url
        /// </summary>
        public static void ApiRouteMatches(HttpConfiguration config, string url)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);
            var request = new HttpRequestMessage(HttpMethod.Get, absoluteUrl);
            var apiRouteGenerator = new ApiRouteGenerator(config, request);

            if (!apiRouteGenerator.HasMatchedRoute)
            {
                var hasRouteMessage = string.Format("Did not match a route for url '{0}'", url);
                Asserts.Fail(hasRouteMessage);
            }
        }
Пример #3
0
 private static IDictionary<string, string> ReadApiRouteProperties(HttpConfiguration config, string url, HttpMethod httpMethod)
 {
     var request = new HttpRequestMessage(httpMethod, url);
     var apiRouteGenerator = new ApiRouteGenerator(config, request);
     return apiRouteGenerator.ReadRouteProperties(url, httpMethod);
 }
Пример #4
0
        /// <summary>
        /// Asserts that the API route does not exist
        /// </summary>
        public static void NoApiRoute(HttpConfiguration config, string url)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);
            var request = new HttpRequestMessage(HttpMethod.Get, absoluteUrl);
            var apiRouteGenerator = new ApiRouteGenerator(config, request);

            if (apiRouteGenerator.IsControllerRouteFound())
            {
                var hasRouteMessage = string.Format("Found route to url '{0}'", url);
                Asserts.Fail(hasRouteMessage);
            }
        }