Beispiel #1
0
        public void CanExecuteBeforeAndAfterHandlers()
        {
            var customContext = new LifecycleHooksSpy();

            _builder
            .Before(() =>
            {
                customContext.Before();
                return(customContext);
            })
            .After(context => { context.After(); })
            .OnRequest(((route, context) =>
            {
                context.Request();
                route.Get("/").To(() =>
                {
                    context.RouteHandler();
                    throw new Exception();
                });
            }));

            StartFrank();

            new RestClient("http://127.0.0.1:8019/").Execute(
                new RestRequest("/", Method.GET)
                );

            customContext.OrderThatMethodsWereCalled.Should().ContainInOrder(
                "before", "request", "route-handler", "after"
                );

            _expectExceptionInTeardown = true;
        }
Beispiel #2
0
        public void CanExecuteBeforeAndAfterHandlers()
        {
            var customContext  = new LifecycleHooksSpy();
            var webApplication = Server.Configure()
                                 .Before(() =>
            {
                customContext.Before();
                return(customContext);
            })
                                 .After(context => { context.After(); })
                                 .OnRequest(((configurer, context) =>
            {
                context.Request();
                configurer.Get("/").To(() =>
                {
                    context.RouteHandler();
                    throw new Exception();
                });
            }))
                                 .StartTesting();

            webApplication.Execute(Get());

            customContext.OrderThatMethodsWereCalled.Should().ContainInOrder(
                "before", "request", "route-handler", "after"
                );
        }