🏗️ structured files for testing

Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
haraldnilsen 2023-10-03 10:03:36 +02:00
parent 5cfc2653bb
commit d4b53e9912
15 changed files with 4 additions and 5 deletions

View file

@ -38,14 +38,13 @@ using (var scope = services.CreateScope())
var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>(); var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>();
context.Database.EnsureCreated(); context.Database.EnsureCreated();
using (context)
{
context.Database.Migrate();
}
// Check if movies are already inserted to avoid duplicate insertion // Check if movies are already inserted to avoid duplicate insertion
if (!context.Movies.Any()) if (!context.Movies.Any())
{ {
using (context)
{
context.Database.Migrate();
}
using (var reader = new StreamReader("public/DbMockData.csv")) using (var reader = new StreamReader("public/DbMockData.csv"))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{ {