public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new GlDbContext(serviceProvider.GetRequiredService <DbContextOptions <GlDbContext> >()))
            {
                context.Database.EnsureCreated();

                // Seed data when first run
                if (!context.Airports.Any())
                {
                    new DataSeeder().SeedData(context);
                }
            }
        }
Exemple #2
0
        public static void ClassInitialize(TestContext context)
        {
            var options = new DbContextOptionsBuilder <GlDbContext>()
                          .UseInMemoryDatabase(databaseName: "Test_database")
                          .Options;

            var dbContext = new GlDbContext(options);

            dbContext.Database.EnsureCreated();

            // Seed data when first run
            if (!dbContext.Airports.Any())
            {
                new DataSeeder().SeedData(dbContext);
            }

            _routeService = new RouteService(dbContext);
        }
Exemple #3
0
 public RouteService(GlDbContext dbContext)
 {
     _dbContext = dbContext;
 }