public async Task IMiddlewareBuilder_UseRoutingDataExtractor_Simple()
        {
            // arrange
            var tracer     = new Tracer();
            var middleware = new MiddlewareBuilder <Context>()
                             .Use(tracer.TestMiddleware("A"))
                             .UseRoutingKey(c => c.Features.Get <string>(),
                                            "^(?<area>.*)-home-(?<action>.*)$",
                                            "^xyz\\.(?<action>.*)$"
                                            )
                             .UseRoutes(
                new Route <Context>(StringRouter.Match("action", "create"), b => b.Use(tracer.TestMiddleware("B"))),
                new Route <Context>(StringRouter.Match("action", "delete"), b => b.Use(tracer.TestMiddleware("C")))
                )
                             .Build();

            // act
            var context = new Context();

            context.Features.Set("xyz.delete");
            await middleware(context);

            // assert
            Assert.Equal("AC", tracer.Trace);
        }
        public async Task IMiddlewareBuilder_UseRoutingKey_Simple()
        {
            // arrange
            var tracer     = new Tracer();
            var middleware = new MiddlewareBuilder <Context>()
                             .Use(tracer.TestMiddleware("A"))
                             .UseRoutingKey(c => c.Features.Get <string>())
                             .UseRoutes(
                new Route <Context>(StringRouter.ByRoutingKey("xyz.create"), b => b.Use(tracer.TestMiddleware("B"))),
                new Route <Context>(StringRouter.ByRoutingKey("xyz.delete"), b => b.Use(tracer.TestMiddleware("C")))
                )
                             .Build();

            // act
            var context = new Context();

            context.Features.Set("xyz.delete");
            await middleware(context);

            // assert
            Assert.Equal("AC", tracer.Trace);
        }
        public async Task IEndpointRouteBuilder_MapLambda_EndpointBuilderRequires()
        {
            // arrange
            string result = "";

            var stack = new MiddlewareBuilder <Context>()
                        .UseRouting()
                        .UseRoutingKey(c => c.Feature <string>(), @"^(?<xyz>.*)/(?<action>.*)$")
                        .UseEndpoints(endpoints =>
            {
                endpoints.MapLambda("X", _ => result = "X")
                .Requires(StringRouter.Match("action", "X"));
                endpoints.MapLambda("Y", _ => result = "Y")
                .Requires(StringRouter.Match("action", "Y"));
            })
                        .Build();

            // act
            await stack(new Context("x/Y"));

            // assert
            Assert.Equal("Y", result);
        }