Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public MovieGenresController(MovieDbLiteContext context)
 {
     _context = context;
 }
Esempio n. 5
0
 public FilmMembersController(MovieDbLiteContext context)
 {
     _context = context;
 }
 public MovieImagesController(MovieDbLiteContext context)
 {
     _context = context;
 }
 public MovieCastMembersController(MovieDbLiteContext context)
 {
     _context = context;
 }
Esempio n. 8
0
 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;
 }
Esempio n. 12
0
 public LanguagesController(MovieDbLiteContext context)
 {
     _context = context;
 }
 public MovieDetailsController(MovieDbLiteContext context)
 {
     _context = context;
 }
 public TheMovieDbApiController(MovieDbLiteContext context)
 {
     _context = context;
 }
Esempio n. 15
0
 public UsersController(MovieDbLiteContext context)
 {
     _context = context;
 }
 public RestrictionRatingsController(MovieDbLiteContext context)
 {
     _context = context;
 }
Esempio n. 17
0
 public ReportsController(MovieDbLiteContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public AwardsController(MovieDbLiteContext context)
 {
     _context = context;
 }