// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); var mvcBuilder = services.AddRazorPages(); #if DEBUG mvcBuilder.AddRazorRuntimeCompilation(); #endif // Register the services services.AddSingleton(VehicleImageService.InitializeCosmosClientInstanceAsync( Configuration.GetSection("CosmosDb:VehicleImages")).GetAwaiter().GetResult()); // TODO other services or registrations for other db entities }
public ServicesFixture() { Configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile("appsettings.Testing.json") .Build(); this.Services = new ServiceCollection(); // Register the services this.Services.AddSingleton(VehicleImageService.InitializeCosmosClientInstanceAsync( Configuration.GetSection("CosmosDb:VehicleImages")).GetAwaiter().GetResult()); // Build the Service Provider this.ServiceProvider = this.Services.BuildServiceProvider(); }