private void DropInMemory(TestDbContextOptionsCache <TContext> cache, string instanceName)
        {
            if (cache.ContainsKey(instanceName))
            {
                _logger.LogInformation($"Dropping in-memory history instance {instanceName} for {typeof(TContext).Name}");
                var options = cache[instanceName];
                TestDbContextManager <TContext> .DropInMemoryDatabase(options);

                cache.Remove(instanceName);
            }
        }
        private void GetOrAddInMemoryDatabase(TRepo repo, TestDbContextOptionsCache <TContext> cache,
                                              string instanceName, string baseDatabaseName)
        {
            if (cache.ContainsKey(instanceName))
            {
                TestDbContextManager <TContext> .CreateInMemoryDatabase(cache[instanceName], out TContext context);

                repo.Context = context;
                _logger.LogInformation($"Using existing in-memory database {baseDatabaseName}, instance = {instanceName}");
            }
            else
            {
                _logger.LogInformation($"Creating in-memory database {baseDatabaseName}, instance = {instanceName}");
                TestDbContextManager <TContext> .CreateInMemoryDatabase(baseDatabaseName, instanceName,
                                                                        out DbContextOptions <TContext> options, out TContext context);

                repo.Context = context;
                repo.Context.Database.EnsureCreated();
                cache.Add(instanceName, options);
            }
        }