Summary

Class:ProjectX.PublicApi.Program
Assembly:ProjectX.PublicApi
File(s):C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Program.cs
Covered lines:0
Uncovered lines:36
Coverable lines:36
Total lines:59
Line coverage:0%
Branch coverage:0%

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
Main(...)1000
RunService(...)2000

File(s)

C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Program.cs

#LineLine coverage
 1using System.IO;
 2using Microsoft.AspNetCore.Builder;
 3using Microsoft.AspNetCore.Hosting;
 4using Microsoft.Extensions.Configuration;
 5using Microsoft.Extensions.Configuration.UserSecrets;
 6using Serilog;
 7
 8// [assembly: UserSecretsId("ProjectX.PublicApi")]
 9
 10namespace ProjectX.PublicApi
 11{
 12    public class Program
 13    {
 14        public static void Main(string[] args)
 15        {
 016            RunService<Startup>(Directory.GetCurrentDirectory(), args);
 017        }
 18
 19        public static void RunService<TStartup>(
 20            string contentRoot,
 21            string[] args) where TStartup : Startup
 22        {
 023            var hostBuilder = new WebHostBuilder()
 024               .UseKestrel()
 025               .UseUrls("http://*:8081")
 026               .UseContentRoot(contentRoot)
 027               .ConfigureAppConfiguration((builderContext, configBuilder) =>
 028               {
 029                   var env = builderContext.HostingEnvironment;
 030
 031                   configBuilder.AddJsonFile("./AppData/config.json",
 032                                               optional: false,
 033                                               reloadOnChange: false);
 034
 035                    if (env.IsDevelopment())
 036                   {
 037                       configBuilder.AddUserSecrets<TStartup>();
 038                   }
 039
 040                   configBuilder.AddEnvironmentVariables();
 041                   configBuilder.AddCommandLine(args);
 042               })
 043               .ConfigureLogging((hostingContext, logging) =>
 044               {
 045                   var serilogOptions = hostingContext
 046                       .Configuration.GetSection("Serilog");
 047
 048                   var logger = new LoggerConfiguration()
 049                       .ReadFrom.ConfigurationSection(serilogOptions)
 050                       .CreateLogger();
 051
 052                   logging.AddSerilog(logger, true);
 053               })
 054               .UseStartup<TStartup>();
 55
 056            hostBuilder.Build().Run();
 057        }
 58    }
 59}