Beispiel #1
0
        private string CreateDataTest()
        {
            var nameDB  = Guid.NewGuid().ToString();
            var context = BuildContext(nameDB);
            var gender  = new Gender()
            {
                Name = "genero 1"
            };

            var movies = new List <Movie>()
            {
                new Movie()
                {
                    Title = "Película 1", PremireDate = new DateTime(2010, 1, 1), InTheaters = false
                },
                new Movie()
                {
                    Title = "No estrenada", PremireDate = DateTime.Today.AddDays(1), InTheaters = false
                },
                new Movie()
                {
                    Title = "Película en Cines", PremireDate = DateTime.Today.AddDays(-1), InTheaters = true
                }
            };

            var moviesWithGender = new Movie()
            {
                Title       = "Película con Género",
                PremireDate = new DateTime(2010, 1, 1),
                InTheaters  = false
            };

            movies.Add(moviesWithGender);

            context.Add(gender);
            context.AddRange(movies);
            context.SaveChanges();

            var movieGender = new MoviesGenders()
            {
                GenderId = gender.Id, MovieId = moviesWithGender.Id
            };

            context.Add(movieGender);
            context.SaveChanges();

            return(nameDB);
        }
Beispiel #2
0
        private string CreateDataTest()
        {
            var nameDb  = Guid.NewGuid().ToString();
            var context = BuildContext(nameDb);
            var gender  = new Gender()
            {
                Name = "genre 1"
            };

            var movies = new List <Movie>()
            {
                new Movie()
                {
                    Title = "Movie 1", PremiereDate = new DateTime(2010, 1, 1), InTheaters = false
                },
                new Movie()
                {
                    Title = "Not released", PremiereDate = DateTime.Today.AddDays(1), InTheaters = false
                },
                new Movie()
                {
                    Title = "Movie in theaters", PremiereDate = DateTime.Today.AddDays(-1), InTheaters = true
                }
            };

            var movieWithGender = new Movie()
            {
                Title        = "Movies with Gender",
                PremiereDate = new DateTime(2010, 1, 1),
                InTheaters   = false
            };

            movies.Add(movieWithGender);

            context.Add(gender);
            context.AddRange(movies);
            context.SaveChanges();

            var movieGender = new MoviesGenders()
            {
                GenderId = gender.Id, MovieId = movieWithGender.Id
            };

            context.Add(movieGender);
            context.SaveChanges();

            return(nameDb);
        }