public static async Task SeedAsync(BotCoreTestContext context, ICurrencyService currencyService, int retry = 0) { var retryForAvailability = retry; try { // TODO: Only run this if using a real database await context.Database.MigrateAsync(); if (!context.Currency.Any()) { var currencies = await currencyService.GetAllCurrencies(); await context.Currency.AddRangeAsync(currencies); await context.Currency.AddAsync(GetByn()); await context.SaveChangesAsync(); } } catch (Exception) { if (retryForAvailability >= 10) { throw; } retryForAvailability++; await SeedAsync(context, currencyService, retryForAvailability); throw; } }
public GenericRepository(BotCoreTestContext dbContext) { DbContext = dbContext; }