// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, ApplicationDbContext db) { app.Use(async(ctx, next) => { await next(); if (ctx.Response.StatusCode == 204) { ctx.Response.ContentLength = 0; } }); if (env.IsDevelopment()) { app.UseCors("AllowAll"); app.UseMiddleware <MaintainCorsHeadersMiddleware>(); app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Simple receipt api"); c.RoutePrefix = "api"; c.DocExpansion(DocExpansion.None); }); // ===== Error handling middleware ===== app.ConfigureExceptionHandler(); // ===== Use Authentication ====== app.UseAuthentication(); app.UseHttpsRedirection(); app.UseMvc(); // ===== For angular app in wwwwroot ==== app.UseDefaultFiles(); app.UseStaticFiles(); // For the wwwroot folder // ===== Create tables ====== db.Database.Migrate(); CreateRoles(serviceProvider, db).Wait(); // ===== Automapper ====== ServiceAutomapper.Configure(); AutoMapper.Mapper.AssertConfigurationIsValid(); }
public static void ClassInitialize(TestContext context) { ServiceAutomapper.Configure(); }