public static int Main(string[] args) { ConfigureLoggingExtension.ConfigureDefaultSerilogLogger(); try { CreateHostBuilder(args).Build().Run(); return(0); }catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); return(1); } }
protected ApiTestFixture(string relativeTargetProjectParentDir) { ConfigureLoggingExtension.ConfigureDefaultSerilogLogger(); var contentRoot = GetProjectPath(relativeTargetProjectParentDir); var configurationBuilder = new ConfigurationBuilder() .SetBasePath(contentRoot) .AddJsonFile("appsettings.Testing.json") .AddEnvironmentVariables("ASPNETCORE"); var webHostBuilder = new WebHostBuilder() .UseConfiguration(configurationBuilder.Build()) .UseContentRoot(contentRoot) .ConfigureServices(InitializeServices) .Configure(Configure) .UseEnvironment("Testing") .UseStartup(typeof(Startup)) .UseSerilog(); // Create instance of test server Server = new TestServer(webHostBuilder); // Add configuration for client JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }; Client = Server.CreateClient(); Client.BaseAddress = Server.BaseAddress; Client.DefaultRequestHeaders.Accept.Clear(); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); ODataClient = new ODataClient($"{Server.BaseAddress}api/"); ServiceProvider = Server.Services; }