Ejemplo n.º 1
0
        public void route_tostring_overrides_with_function_wrapped_method()
        {
            var method = typeof(RouteTestingHelper).GetMethod("RouteOne");
            Func <IHttpContext, IHttpContext> function = new RouteTestingHelper().RouteOne;
            var pathinfo = "/path/to/resource";
            var route    = new Route(function, HttpMethod.GET, pathinfo);

            route.ToString().ShouldBe($"{HttpMethod.GET} {pathinfo} > {method.ReflectedType.FullName}.{method.Name}");
        }
Ejemplo n.º 2
0
        public void route_invoke_using_static_method()
        {
            var route   = new Route(typeof(RouteTestingHelper).GetMethod("StaticRoute"));
            var context = TestingMocks.MockContext();

            route.Invoke(context);

            RouteTestingHelper.WhoTriggeredMe().ShouldBe("StaticRoute");
        }
Ejemplo n.º 3
0
        public void route_invoke_using_function_wrapped_method()
        {
            Func <IHttpContext, IHttpContext> function = new RouteTestingHelper().RouteTwo;
            var route   = new Route(function);
            var context = TestingMocks.MockContext();

            route.Invoke(context);

            RouteTestingHelper.WhoTriggeredMe().ShouldBe("RouteTwo");
        }
Ejemplo n.º 4
0
        public void route_equality_true_when_routes_created_using_same_underlying_method()
        {
            var method = typeof(RouteTestingHelper).GetMethod("RouteOne");
            Func <IHttpContext, IHttpContext> function = new RouteTestingHelper().RouteOne;

            var verb     = HttpMethod.GET;
            var pathinfo = "/path/[param1]/[param2]";

            var route1 = new Route(method, verb, pathinfo);
            var route2 = new Route(function, verb, pathinfo);

            route1.Equals(route2).ShouldBe(true);
        }
Ejemplo n.º 5
0
        public void route_invoke_using_function()
        {
            var triggeredBy = "Anon";
            var context     = TestingMocks.MockContext();
            var route       = new Route(ctx =>
            {
                RouteTestingHelper.WasTriggeredBy(triggeredBy);
                return(ctx);
            });

            route.Invoke(context);

            RouteTestingHelper.WhoTriggeredMe().ShouldBe(triggeredBy);
        }