Ejemplo n.º 1
0
        public void GetMoviesByProducerTest()
        {
            Movie movie = new Movie();

            movie.Name     = "Harry Potter and the Philosopher's Stone";
            movie.Date     = new DateTime(2001, 11, 4);
            movie.Producer = "Chris Columbus";
            movie.Actors   = "Daniel Radcliffe, Rupert Grint, Emma Watson";
            movie.Genre    = "fantasy";
            movie.Duration = 152;
            MovieDAO movieDAO = new MovieDAO();

            movieDAO.AddMovie(movie);
            List <string> expected = new List <string>();

            expected.Add(ToStringWithoutId(movie));

            movie          = new Movie();
            movie.Name     = "Harry Potter and the Chamber of Secrets";
            movie.Date     = new DateTime(2002, 11, 3);
            movie.Producer = "Chris Columbus";
            movie.Actors   = "Daniel Radcliffe, Rupert Grint, Emma Watson";
            movie.Genre    = "fantasy";
            movie.Duration = 161;
            movieDAO.AddMovie(movie);
            expected.Add(ToStringWithoutId(movie));

            List <Movie> list = movieDAO.GetMoviesByProducer(movie.Producer);

            if (list == null || list.Count < 2)
            {
                Assert.Fail();
            }
            List <string> actual = new List <string>();

            for (int i = list.Count - 2; i < list.Count; i++)
            {
                actual.Add(ToStringWithoutId(list[i]));
            }

            CollectionAssert.AreEqual(expected, actual);
        }