Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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();
        }
Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo n.º 7
0
        public void AbsoluteUrlIsUnchanged()
        {
            var outputUrl = UrlHelpers.MakeAbsolute("http://foo.com");

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

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

            Assert.That(outputUrl, Is.EqualTo("http://site.com/"));
        }
Exemplo 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"));
        }
Exemplo 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);
        }
Exemplo n.º 12
0
        internal static void HasRoute(HttpConfiguration config, string url, HttpMethod httpMethod)
        {
            var absoluteUrl = UrlHelpers.MakeAbsolute(url);

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