public static TestServer Create(IServiceProvider provider, Action <IApplicationBuilder> app) { var appEnv = provider.GetRequiredService <IApplicationEnvironment>(); var hostingEnv = new HostingEnvironment() { EnvironmentName = DefaultEnvironmentName, WebRoot = HostingUtilities.GetWebRoot(appEnv.ApplicationBasePath), }; var collection = new ServiceCollection(); collection.Add(HostingServices.GetDefaultServices()); collection.AddInstance <IHostingEnvironment>(hostingEnv); var appServices = collection.BuildServiceProvider(provider); var config = new Configuration(); return(new TestServer(config, appServices, app)); }
public void ReadWebRootFromProjectJson() { var root = HostingUtilities.GetWebRoot("."); Assert.True(root.EndsWith("testroot")); }