public void Configure(IBlazorApplicationBuilder app, WebsitesContext context) { //Populate initial data context.SeedData().GetAwaiter().GetResult(); app.AddComponent <App>("app"); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, WebsitesContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); var options = new HealthCheckOptions(); options.ResponseWriter = async(c, r) => { c.Response.ContentType = "application/json"; var result = JsonConvert.SerializeObject(new { status = r.Status.ToString(), errors = r.Entries.Select(e => new { key = e.Key, value = e.Value.Status.ToString() }) }); await c.Response.WriteAsync(result); }; app.UseHealthChecks("/working", options); app.UseHealthChecksUI(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); //For MSSql //context.Database.Migrate(); //Populate initial data context.SeedData().GetAwaiter().GetResult(); }
public void Setup() { var services = new ServiceCollection(); services.AddDbContext <WebsitesContext>(options => options.UseInMemoryDatabase(), ServiceLifetime.Singleton); services.AddSingleton <WebsiteDataService>(); var serviceProvider = services.BuildServiceProvider(); testContext = serviceProvider.GetService <WebsitesContext>(); testContext.SeedData().GetAwaiter().GetResult(); websiteService = new WebsiteDataService(testContext); }
public void SetUp() { var services = new ServiceCollection(); services.AddDbContext <WebsitesContext>(options => options.UseInMemoryDatabase(), ServiceLifetime.Singleton); services.AddSingleton <WebsitesController>(); services.AddSingleton <SampleDataController>(); var serviceProvider = services.BuildServiceProvider(); _testContext = serviceProvider.GetService <WebsitesContext>(); _testContext.SeedData().GetAwaiter().GetResult(); _websitesController = serviceProvider.GetService <WebsitesController>(); _sampleDataController = serviceProvider.GetService <SampleDataController>(); }