private static void SeedData(MovieDbLiteContext dbContext) { dbContext.RestrictionRating.Add(new RestrictionRating() { Id = (int)MVC.DbEnum.RestrictionRating.G, Code = "G", ShortDescription = "G", LongDescription = "Don't Matter", IsActive = true }); dbContext.RestrictionRating.Add(new RestrictionRating() { Id = (int)MVC.DbEnum.RestrictionRating.PG, Code = "PG", ShortDescription = "G", LongDescription = "Don't Matter", IsActive = true }); dbContext.Genre.Add(new MVC.Models.Genre() { Id = 1, GenreName = "Thriller", }); dbContext.Genre.Add(new MVC.Models.Genre() { Id = 2, GenreName = "Action", }); dbContext.SaveChanges(); }
public async Task Post_WillCreateMovieDbLiteMovie_WithBasicDetails() { // Arrange var builder = new DbContextOptionsBuilder <MovieDbLiteContext>(); builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); using var dbContext = new MovieDbLiteContext(builder.Options); SeedData(dbContext); using var testContext = new MovieDbLiteContext(builder.Options); DbOrgMovie dbOrgMovie = CreateObjectWithoutLanguagesAndRestrictionRating(); var theMovieDbApiController = new TheMovieDbApiController(testContext); await theMovieDbApiController.Post(dbOrgMovie); using var retrieveContext = new MovieDbLiteContext(builder.Options); var movies = await retrieveContext.Movie.Include(m => m.MovieGenre).ToListAsync(); Assert.AreEqual(1, movies.Count); Movie newMovie = movies[0]; Assert.AreEqual("Football Movie", newMovie.Title); Assert.AreEqual(150, newMovie.DurationInMinutes); Assert.AreEqual(new DateTime(2020, 05, 08), newMovie.ReleaseDate); Assert.AreEqual(2, newMovie.MovieGenre.Count); Assert.IsTrue(newMovie.MovieGenre.Any(mg => mg.GenreId == 1)); Assert.IsTrue(newMovie.MovieGenre.Any(mg => mg.GenreId == 2)); Assert.IsNull(newMovie.RestrictionRatingId); }
public async Task TestInMemoryDatabaseWorksWithSeed() { // Arrange var builder = new DbContextOptionsBuilder <MovieDbLiteContext>(); builder.UseInMemoryDatabase("MovieDbLiteMemory"); using var dbContext = new MovieDbLiteContext(builder.Options); SeedData(dbContext); using var testContext = new MovieDbLiteContext(builder.Options); int count = await testContext.RestrictionRating.CountAsync(); Assert.AreEqual(2, count); }
public MovieGenresController(MovieDbLiteContext context) { _context = context; }
public FilmMembersController(MovieDbLiteContext context) { _context = context; }
public MovieImagesController(MovieDbLiteContext context) { _context = context; }
public MovieCastMembersController(MovieDbLiteContext context) { _context = context; }
public AwardShowInstancesController(MovieDbLiteContext context) { _context = context; }
public MovieUserReviewsController(MovieDbLiteContext context) { _context = context; }
public FilmRolesController(MovieDbLiteContext context) { _context = context; }
public AwardWinnersController(MovieDbLiteContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public LanguagesController(MovieDbLiteContext context) { _context = context; }
public MovieDetailsController(MovieDbLiteContext context) { _context = context; }
public TheMovieDbApiController(MovieDbLiteContext context) { _context = context; }
public UsersController(MovieDbLiteContext context) { _context = context; }
public RestrictionRatingsController(MovieDbLiteContext context) { _context = context; }
public ReportsController(MovieDbLiteContext context) { _context = context; }
public AwardsController(MovieDbLiteContext context) { _context = context; }