private void UrlWhitespaceSetsDefault()
        {
            var requestDelegate = new RequestDelegate(CreateDefaultHttpContext);
            var middleware      = new SwaggerUiRedirectMiddleware(requestDelegate, "   ");

            Assert.Equal(Defaults.Swagger.Url, middleware.Url);
        }
        private void UrlIsSet()
        {
            var requestDelegate = new RequestDelegate(CreateDefaultHttpContext);
            var middleware      = new SwaggerUiRedirectMiddleware(requestDelegate, "myUrl");

            Assert.Equal("myUrl", middleware.Url);
        }
        private void NextDelegateIsSet()
        {
            var requestDelegate = new RequestDelegate(CreateDefaultHttpContext);
            var middleware      = new SwaggerUiRedirectMiddleware(requestDelegate, null);

            Assert.Same(requestDelegate, middleware.NextDelegate);
        }
        private async void NonRootRequestDoesNotRedirect()
        {
            var requestDelegate = new RequestDelegate(CreateDefaultHttpContext);
            var middleware      = new SwaggerUiRedirectMiddleware(requestDelegate, "myUrl");

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Path = "/api/anotherUrl";

            await middleware.Invoke(httpContext);

            Assert.Equal(httpContext.Response.StatusCode, 200);
            Assert.Equal(0, httpContext.Response.Headers.Count);
        }
        private async void RootRequestRedirectsToUrl()
        {
            var requestDelegate = new RequestDelegate(CreateDefaultHttpContext);
            var middleware      = new SwaggerUiRedirectMiddleware(requestDelegate, "myUrl");

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Path = "/";

            await middleware.Invoke(httpContext);

            Assert.Equal(httpContext.Response.StatusCode, 302);
            Assert.Equal(1, httpContext.Response.Headers.Count);
            Assert.Equal(1, httpContext.Response.Headers["location"].Count);
            Assert.Equal("myUrl", httpContext.Response.Headers["location"].ToArray().First());
        }