Example #1
0
        public static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                         .Enrich.FromLogContext()
                         .WriteTo.Console()
                         .WriteTo.File(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "THA", "THA.log.txt"),
                                       rollingInterval: RollingInterval.Day,
                                       rollOnFileSizeLimit: true)
                         .CreateLogger();

            try
            {
                Log.Information("Starting web host");

                var host = CreateHostBuilder(args).Build();

                //Populate dummy data into in memory db
                PopulateUsers.PopulateUserIfNotExist(host.Services);
                PopulateProducts.PopulateProductsIfNotExist(host.Services);

                host.Run();
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly");
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
Example #2
0
        //private readonly HttpClient _client;



        public ProductAPITest()
        {
            // Arrange
            var host = new WebHostBuilder()
                       .UseEnvironment("Development")
                       .UseConfiguration(
                new ConfigurationBuilder().AddJsonFile("appsettings.development.json").Build()
                )
                       .UseSerilog()
                       .UseStartup <Startup>();

            _server = new TestServer(host);
            //_client = _server.CreateClient();

            //mock dummy data into in memory db
            PopulateUsers.PopulateUserIfNotExist(_server.Host.Services);
            PopulateProducts.PopulateProductsIfNotExist(_server.Host.Services);
        }