Esempio n. 1
0
        public void TestInitDB()
        {
            Database.SetInitializer <MovieDBContext>(new MovieInitializer());
            var db = new MovieDBContext();

            Assert.AreEqual(2, db.Movies.Count());
        }
Esempio n. 2
0
        public void TestInsertMovies()
        {
            var dbContext = new MovieDBContext();
            var movie     = new Movie {
                Title       = "大话西游",
                ReleaseDate = DateTime.Parse("1994-1-1"),
                Genre       = "Comedy",
                Rating      = "R",
                Price       = 99.999M
            };

            dbContext.Movies.Add(movie);
            dbContext.SaveChanges();
            Assert.AreEqual("大话西游", dbContext.Movies.OrderByDescending(a => a.ID).Select(a => a.Title).FirstOrDefault());
        }
Esempio n. 3
0
        public void TestInsertActors()
        {
            var dbContext = new MovieDBContext();
            var actor     = new Actor
            {
                Name     = "XXX",
                theMovie = new Movie
                {
                    Title       = "大话西游2",
                    ReleaseDate = DateTime.Parse("2013-1-1"),
                    Genre       = "Comedy",
                    Rating      = "R",
                    Price       = 999.999M
                },
            };

            dbContext.Actors.Add(actor);
            dbContext.SaveChanges();
        }