public IApplicationBuilder Use() { var routeBuilder = new Microsoft.AspNetCore.Routing.RouteBuilder(App); foreach (RouteBuilder route in AllRoutes) { route.AddRoutes(routeBuilder); } return(App.UseRouter(routeBuilder.Build())); }
private static IRouteBuilder CreateRouteBuilder(IServiceProvider services) { var applicationBuilder = new Mock <IApplicationBuilder>(); applicationBuilder.SetupAllProperties(); applicationBuilder .Setup(b => b.New().Build()) .Returns(NullHandler); applicationBuilder.Object.ApplicationServices = services; var routeBuilder = new RouteBuilder(applicationBuilder.Object); return(routeBuilder); }
public void Ctor_SetsPropertyValues() { // Arrange var services = new ServiceCollection(); services.AddSingleton(typeof(RoutingMarkerService)); var applicationServices = services.BuildServiceProvider(); var applicationBuilderMock = new Mock <IApplicationBuilder>(); applicationBuilderMock.Setup(a => a.ApplicationServices).Returns(applicationServices); var applicationBuilder = applicationBuilderMock.Object; var defaultHandler = Mock.Of <IRouter>(); // Act var builder = new RouteBuilder(applicationBuilder, defaultHandler); // Assert Assert.Same(applicationBuilder, builder.ApplicationBuilder); Assert.Same(defaultHandler, builder.DefaultHandler); Assert.Same(applicationServices, builder.ServiceProvider); }