private static async Task UpdateTheItemsFromDatabase(GenerationEnvironment[] environments, IEnumerable <ItemFromFile> uniqueItems) { var mapper = GetMapper(); var items = uniqueItems.Select(item => mapper.Map <Item>(item)).ToList(); var itemProperties = items.SelectMany(item => item.Properties).ToList(); var configurationFilePaths = environments.Select(environment => $"appsettings.{environment.ToString()}.json"); foreach (var configurationFilePath in configurationFilePaths) { var configuration = ConfigurationHelpers.GetMyConfiguration(configurationFilePath); var connectionString = DatabaseHelpers.GetMyConnectionString(configuration, nameof(DiabloII.Items.Generator)); using (var dbContext = DatabaseHelpers.GetMyDbContext(connectionString)) { dbContext.Database.SetCommandTimeout(CommandTimeout); dbContext.Database.Migrate(); var itemRepository = new ItemRepository(dbContext); var command = new ResetItemsCommand { Items = items, ItemProperties = itemProperties }; await new ItemCommandHandler(itemRepository, dbContext).Handle(command); } } }
public void Database_ShouldResponse() { var connectionString = DatabaseHelpers.GetMyConnectionString(_configuration, "Diablo II Documentation - Tests"); using (var dbContext = DatabaseHelpers.GetMyDbContext(connectionString)) { dbContext.Database.SetCommandTimeout(5); var canConnectToTheDatabase = dbContext.Database.CanConnect(); canConnectToTheDatabase.ShouldBe(true, "The production database don't respond."); } }