Esempio n. 1
0
        public static void RouteDoesNotHaveMethod(HttpConfiguration config, string url, Type controllerType, HttpMethod httpMethod)
        {
            var absoluteUrl    = UrlHelpers.MakeAbsolute(url);
            var request        = new HttpRequestMessage(httpMethod, absoluteUrl);
            var routeGenerator = new Generator(config, request);

            routeGenerator.CheckControllerHasNoMethod(url, httpMethod, controllerType);
        }
Esempio n. 2
0
        internal static void RouteDoesNotHaveMethod(HttpConfiguration config, string url, HttpMethod httpMethod)
        {
            var absoluteUrl    = UrlHelpers.MakeAbsolute(url);
            var request        = new HttpRequestMessage(httpMethod, absoluteUrl);
            var routeGenerator = new Generator(config, request);

            routeGenerator.CheckNoMethod(url, httpMethod);
        }
Esempio n. 3
0
        internal static void HasRoute(HttpConfiguration config, string url, HttpMethod httpMethod, Dictionary <string, string> headers, string body, BodyFormat bodyFormat, RouteValues expectedProps)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);
            var actualProps = ReadRequestProperties(config, absoluteUrl, httpMethod, headers, body, bodyFormat);

            var verifier = new Verifier(expectedProps, actualProps, url);

            verifier.VerifyExpectations();
        }
Esempio n. 4
0
        internal static void NoRouteMatches(HttpConfiguration config, string url)
        {
            var absoluteUrl    = UrlHelpers.MakeAbsolute(url);
            var request        = new HttpRequestMessage(HttpMethod.Get, absoluteUrl);
            var routeGenerator = new Generator(config, request);

            if (routeGenerator.HasMatchedRoute)
            {
                var hasRouteMessage = string.Format("Matched a route for url '{0}'", url);
                Asserts.Fail(hasRouteMessage);
            }
        }
Esempio n. 5
0
        internal static void HasNoHandlerofType <THandler>(HttpConfiguration config, string url) where THandler : HttpMessageHandler
        {
            var absoluteUrl    = UrlHelpers.MakeAbsolute(url);
            var request        = new HttpRequestMessage(HttpMethod.Get, absoluteUrl);
            var routeGenerator = new Generator(config, request);

            if (routeGenerator.HasHandlerOfType <THandler>())
            {
                var hasHandlerMessage = string.Format("Matching handler of type '{0}' found for url '{1}'.",
                                                      routeGenerator.HandlerType().Name, absoluteUrl);
                Asserts.Fail(hasHandlerMessage);
            }
        }
Esempio n. 6
0
        internal static void HasHandler <THandler>(HttpConfiguration config, string url) where THandler : HttpMessageHandler
        {
            var absoluteUrl    = UrlHelpers.MakeAbsolute(url);
            var request        = new HttpRequestMessage(HttpMethod.Get, absoluteUrl);
            var routeGenerator = new Generator(config, request);

            if (!routeGenerator.HasHandlerOfType <THandler>())
            {
                var actualHandlerType = routeGenerator.HandlerType();
                var failureMessage    = string.Format("Did not match handler type '{0}' for url '{1}', found ", typeof(THandler).Name, absoluteUrl);
                if (actualHandlerType != null)
                {
                    failureMessage += string.Format("a handler of type '{0}'.", actualHandlerType.Name);
                }
                else
                {
                    failureMessage += "no handler.";
                }
                Asserts.Fail(failureMessage);
            }
        }
Esempio n. 7
0
        public void AbsoluteUrlIsUnchanged()
        {
            var outputUrl = UrlHelpers.MakeAbsolute("http://foo.com");

            Assert.That(outputUrl, Is.EqualTo("http://foo.com"));
        }
Esempio n. 8
0
        public void NonEmptySlashRelativeUrlIsPrefixed()
        {
            var outputUrl = UrlHelpers.MakeAbsolute("/customers/1");

            Assert.That(outputUrl, Is.EqualTo("http://site.com/customers/1"));
        }
Esempio n. 9
0
        public void EmptyRelativeSlashUrlIsPrefixed()
        {
            var outputUrl = UrlHelpers.MakeAbsolute("/");

            Assert.That(outputUrl, Is.EqualTo("http://site.com/"));
        }
Esempio n. 10
0
        public void FtpHttpsUrlIsUnchanged()
        {
            var outputUrl = UrlHelpers.MakeAbsolute("ftp://bar.com/filez.zip");

            Assert.That(outputUrl, Is.EqualTo("ftp://bar.com/filez.zip"));
        }
Esempio n. 11
0
        internal static void HasRoute(HttpConfiguration config, string url, HttpMethod httpMethod, Dictionary <string, string> headers)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);

            ReadRequestProperties(config, absoluteUrl, httpMethod, headers, string.Empty, BodyFormat.None);
        }
Esempio n. 12
0
        internal static void HasRoute(HttpConfiguration config, string url, HttpMethod httpMethod)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);

            ReadRequestProperties(config, absoluteUrl, httpMethod, string.Empty);
        }