public async Task WhenNoSession_ShowNoSessionId() { var httpContext = Substitute.For <HttpContext>(); httpContext.Features.Get <IExceptionHandlerPathFeature>() .Returns(new ExceptionHandlerFeature() { Error = new Exception("Exception"), Path = "/Path" }); var sessionService = Substitute.For <ISessionService>(); sessionService.GetUserSession().ThrowsForAnyArgs(new Exception("message")); var logger = Substitute.For <ILogger <Startup> >(); await ErrorService.LogException(httpContext, sessionService, logger); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISessionService sessionService, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var appPath = Configuration.GetSection("CompositeSettings:Path").Value; app.UseStaticFiles(); app.UseHttpsRedirection(); app.UseExceptionHandler(errorApp => errorApp.Run(async context => { await ErrorService.LogException(context, sessionService, logger); context.Response.Redirect(appPath + "/Error"); })); app.UseRouting(); app.UseCors(_corsPolicy); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute("worked", appPath + "/worked", new { controller = "worked", action = "body" }); endpoints.MapControllerRoute("selectskills", appPath + "/selectskills", new { controller = "selectskills", action = "body" }); endpoints.MapControllerRoute("basket", appPath + "/basket", new { controller = "basket", action = "submit" }); endpoints.MapControllerRoute("confirmremove", appPath + "/confirmremove", new { controller = "confirmremove", action = "body" }); endpoints.MapControllerRoute("occupationsearch", appPath + "/occupationsearch/getskillsforoccupation", new { controller = "occupationsearchde", action = "getskillsforoccupation" }); endpoints.MapControllerRoute("occupationsearchdetails", appPath + "/occupationsearchdetails", new { controller = "occupationsearchdetails", action = "body" }); endpoints.MapControllerRoute("occupationsearchauto", appPath + "/occupationsearchauto", new { controller = "occupationsearch", action = "occupationsearchauto" }); endpoints.MapControllerRoute("removed", appPath + "/removed", new { controller = "removed", action = "body" }); endpoints.MapControllerRoute("route", appPath + "/route", new { controller = "route", action = "body" }); endpoints.MapControllerRoute("moreskills", appPath + "/moreskills", new { controller = "moreskills", action = "body" }); endpoints.MapControllerRoute("relatedskills", appPath + "/relatedskills", new { controller = "relatedskills", action = "body" }); endpoints.MapControllerRoute("enterskills", appPath + "/enterskills", new { controller = "enterskills", action = "body" }); endpoints.MapControllerRoute("reload", appPath + "/reload", new { controller = "reload", action = "body" }); endpoints.MapControllerRoute("error", appPath + "/error", new { controller = "error", action = "body" }); endpoints.MapControllerRoute("dysacResults", appPath + "/dysacResults", new { controller = "dysacResults", action = "body" }); }); }