public void UseEndpoint_ServicesNotRegistered_Throws()
        {
            // Arrange
            var app = new ApplicationBuilder(Mock.Of <IServiceProvider>());

            // Act
            var ex = Assert.Throws <InvalidOperationException>(() => app.UseEndpoint());

            // Assert
            Assert.Equal(
                "Unable to find the required services. " +
                "Please add all the required services by calling 'IServiceCollection.AddRouting' " +
                "inside the call to 'ConfigureServices(...)' in the application startup code.",
                ex.Message);
        }
        public void UseEndpoint_WithoutRoutingServicesRegistered_Throws()
        {
            // Arrange
            var services = CreateServices();

            var app = new ApplicationBuilder(services);

            // Act
            var ex = Assert.Throws <InvalidOperationException>(() => app.UseEndpoint());

            // Assert
            Assert.Equal(
                "EndpointRoutingMiddleware must be added to the request execution pipeline before EndpointMiddleware. " +
                "Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseEndpointRouting' " +
                "inside the call to 'Configure(...)' in the application startup code.",
                ex.Message);
        }
        public async Task UseEndpoint_ServicesRegisteredAndEndpointRoutingRegistered_NoMatch_DoesNotSetFeature()
        {
            // Arrange
            var services = CreateServices();

            var app = new ApplicationBuilder(services);

            app.UseRouting(builder => { });
            app.UseEndpoint();

            var appFunc     = app.Build();
            var httpContext = new DefaultHttpContext();

            // Act
            await appFunc(httpContext);

            // Assert
            Assert.Null(httpContext.Features.Get <IEndpointFeature>());
        }