protected TestServerFixture(string relativeTargetProjectParentDir)
        {
            var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;
            var contentRoot     = GetProjectPath(relativeTargetProjectParentDir, startupAssembly);

            Directory.SetCurrentDirectory(contentRoot);

            var builder = new WebHostBuilder()
                          .UseContentRoot(contentRoot)
                          .ConfigureServices(InitializeServices)
                          .UseEnvironment("Development")
                          .UseStartup(typeof(TStartup))
                          //.UseApplicationInsights()
            ;

            _server = new TestServer(builder);

            Client             = _server.CreateClient();
            Client.BaseAddress = new Uri("http://localhost");

            var configuration = _server.Host.Services.GetService(typeof(IConfiguration)) as IConfiguration;

            AppRootPath    = configuration?["AppRootPath"];
            DBKind         = configuration?["DBKind"];
            ImageDirectory = configuration?["ImageDirectory"];
            LiveWebCamURL  = configuration?["LiveWebCamURL"];

            string temp = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER");

            DOTNET_RUNNING_IN_CONTAINER = !string.IsNullOrEmpty(temp) && temp.Equals(true.ToString(), StringComparison.InvariantCultureIgnoreCase);
            //Console.WriteLine($"### temp = {temp}, DOTNET_RUNNING_IN_CONTAINER = {DOTNET_RUNNING_IN_CONTAINER}");

            var db = _server.Host.Services.GetRequiredService <EFGetStarted.AspNetCore.ExistingDb.Models.BloggingContext>();

            if (DBKind.Equals("sqlite", StringComparison.InvariantCultureIgnoreCase))
            {
                db.Database.Migrate();
            }
            else
            {
                db.Database.EnsureCreated();
            }
        }
        /*#region IDisposable Support
         * private bool disposedValue = false; // To detect redundant calls
         *
         * protected virtual void Dispose(bool disposing)
         * {
         *      if (!disposedValue)
         *      {
         *              if (disposing)
         *              {
         *                      // TODO: dispose managed state (managed objects).
         *                      Client.Dispose();
         *                      _server.Dispose();
         *              }
         *
         *              // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
         *              // TODO: set large fields to null.
         *
         *              disposedValue = true;
         *      }
         * }
         *
         * // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
         * // ~TestFixture() {
         * //   // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
         * //   Dispose(false);
         * // }
         *
         * // This code added to correctly implement the disposable pattern.
         * public void Dispose()
         * {
         *      // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
         *      Dispose(true);
         *      // TODO: uncomment the following line if the finalizer is overridden above.
         *      // GC.SuppressFinalize(this);
         * }
         #endregion IDisposable Support*/


        protected override void ConfigureWebHost(IWebHostBuilder builder)
        {
            var contentRoot = GetProjectPath();

            Directory.SetCurrentDirectory(contentRoot);

            builder.UseContentRoot(contentRoot)
            //.ConfigureServices(InitializeServices)
            .UseEnvironment("Development")
            //.UseStartup(typeof(TStartup))
            //.UseApplicationInsights()
            ;

            builder.ConfigureServices(services =>
            {
                // Build the service provider.
                var sp = services.BuildServiceProvider();

                // Create a scope to obtain a reference to the database context (ApplicationDbContext).
                using (var scope = sp.CreateScope())
                {
                    var scopedServices = scope.ServiceProvider;
                    //var db = scopedServices.GetRequiredService<ApplicationDbContext>();
                    //var logger = scopedServices.GetRequiredService<ILogger<CustomWebApplicationFactory<TStartup>>>();

                    //// Ensure the database is created.
                    //db.Database.EnsureCreated();

                    //try
                    //{
                    //	// Seed the database with test data.
                    //	Utilities.InitializeDbForTests(db);
                    //}
                    //catch (Exception ex)
                    //{
                    //	logger.LogError(ex, "An error occurred seeding the " +
                    //		"database with test messages. Error: {Message}", ex.Message);
                    //}

                    var configuration = scopedServices.GetService(typeof(IConfiguration)) as IConfiguration;
                    AppRootPath       = configuration?["AppRootPath"];
                    DBKind            = configuration?["DBKind"];
                    ImageDirectory    = configuration?["ImageDirectory"];
                    LiveWebCamURL     = configuration?["LiveWebCamURL"];

                    string temp = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER");
                    DOTNET_RUNNING_IN_CONTAINER = !string.IsNullOrEmpty(temp) && temp.Equals(true.ToString(), StringComparison.InvariantCultureIgnoreCase);
                    //Console.WriteLine($"### temp = {temp}, DOTNET_RUNNING_IN_CONTAINER = {DOTNET_RUNNING_IN_CONTAINER}");

                    var db = scopedServices.GetRequiredService <DotnetPlayground.Models.BloggingContext>();
                    if (DBKind.Equals("sqlite", StringComparison.InvariantCultureIgnoreCase))
                    {
                        db.Database.Migrate();
                    }
                    else
                    {
                        db.Database.EnsureCreated();
                    }
                }
            });
        }