/// <summary>
        /// Called by xUnit after the class has been created, this bootstraps
        /// the database at the start of the test session.
        /// </summary>
        /// <returns></returns>
        public virtual async Task InitializeAsync()
        {
            _serviceProvider = DbDependentTestApplicationServiceProviderFactory.CreateTestHostProvider();
            var dbInitializer = new TestDatabaseInitializer(_serviceProvider);
            await dbInitializer.InitializeCofoundry();

            await dbInitializer.DeleteTestData();

            _seededEntities = await dbInitializer.SeedGlobalEntities();
        }
        /// <summary>
        /// Creates a new test application instance with a new DI
        /// service scope. The application should be disposed of
        /// when you are done with it.
        /// </summary>
        /// <param name="serviceConfiguration">
        /// Optional service configuration that runs just before the
        /// service collection is built, enabling you to override
        /// services.
        /// </param>
        /// <returns>The newly created application instance.</returns>
        public virtual DbDependentTestApplication Create(Action <IServiceCollection> serviceConfiguration = null)
        {
            if (_serviceProvider == null)
            {
                throw new InvalidOperationException(nameof(DbDependentTestApplicationFactory) + " has not been initialized.");
            }

            var serviceProvider = _serviceProvider;

            if (serviceConfiguration != null)
            {
                // Only build a new service provider if we need to
                serviceProvider = DbDependentTestApplicationServiceProviderFactory.CreateTestHostProvider(serviceConfiguration);
            }

            var app = new DbDependentTestApplication(serviceProvider, _seededEntities);

            return(app);
        }