public async Task RequestDelegateInvokesAction(Delegate @delegate)
        {
            var httpContext = new DefaultHttpContext();

            var requestDelegate = MapActionExpressionTreeBuilder.BuildRequestDelegate(@delegate);

            await requestDelegate(httpContext);

            Assert.True(httpContext.Items["invoked"] as bool?);
        }
        public async Task RequestDelegatePopulatesFromRouteOptionalParameter(Delegate @delegate)
        {
            var httpContext = new DefaultHttpContext();

            var requestDelegate = MapActionExpressionTreeBuilder.BuildRequestDelegate(@delegate);

            await requestDelegate(httpContext);

            Assert.Equal(42, httpContext.Items["input"] as int?);
        }
        public async Task RequestDelegateInvokesAction()
        {
            var invoked = false;

            void TestAction()
            {
                invoked = true;
            }

            var requestDelegate = MapActionExpressionTreeBuilder.BuildRequestDelegate((Action)TestAction);

            await requestDelegate(null !);

            Assert.True(invoked);
        }
        public async Task RequestDelegatePopulatesFromRouteOptionalParameterBasedOnParameterName(Delegate @delegate)
        {
            const string paramName          = "value";
            const int    originalRouteParam = 47;

            var httpContext = new DefaultHttpContext();

            httpContext.Request.RouteValues[paramName] = originalRouteParam.ToString(NumberFormatInfo.InvariantInfo);

            var requestDelegate = MapActionExpressionTreeBuilder.BuildRequestDelegate(@delegate);

            await requestDelegate(httpContext);

            Assert.Equal(47, httpContext.Items["input"] as int?);
        }