Exemple #1
0
        public static void SeedDatabase(CmdDbContext context)
        {
            var actorMovieCollection       = ModelMocks.GetActorMovieCollection();
            var actorsWithEmptyFilmography = ModelMocks.GetActorsWithEmptyFilmography();

            context.AddRange(actorMovieCollection);
            context.AddRange(actorsWithEmptyFilmography);

            context.SaveChanges();
        }
        public static void ClassInit(TestContext testContext)
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var options = new DbContextOptionsBuilder <CmdDbContext>()
                          .UseSqlite(connection)
                          .EnableSensitiveDataLogging()
                          .Options;

            _context = new CmdDbContext(options);
            _context.Database.EnsureCreated();

            _moviesController = new MoviesController(new MoviesHandler(new ActorMovieRepository(_context)));
            _actorsController = new ActorsController(new ActorsHandler(new ActorMovieRepository(_context)));

            DbHelpers.SeedDatabase(_context);
        }
 public ActorMovieRepository(CmdDbContext context)
 {
     _context = context;
 }