예제 #1
0
        public void Genre_get_all_return_all_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);

            facade = new Facade();
            Assert.IsNotNull(facade.GetGenreRepo().GetAll());
            Assert.AreNotEqual(0, facade.GetGenreRepo().GetAll().ToList().Count);
        }
예제 #2
0
        public void Movie_get_by_genre_return_empty_on_no_movies_test()
        {
            Facade facade = new Facade();
            Genre genre = new Genre() { Name = "test" };
            genre = facade.GetGenreRepo().Add(genre);

            facade = new Facade();
            Assert.AreEqual(facade.GetMovieRepo().GetMovieByGenre(genre).ToList().Count, 0);
        }
예제 #3
0
        public void Genre_added_on_call_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);
            Context context = new Context();

            Assert.IsNotNull(context.Genres.FirstOrDefault(x=> x.Id == temp.Id));
            Assert.AreNotEqual(temp.Id, 0);
        }
예제 #4
0
        public void Genre_getgenrebymovie_return_multiple_test()
        {
            Facade facade = new Facade();
            Genre genre = new Genre() { Name = "test1" };
            Genre genretwo = new Genre() { Name = "test2" };
            List<Genre> list = new List<Genre>();
            //genre = facade.GetGenreRepo().Add(genre);
            //genretwo = facade.GetGenreRepo().Add(genretwo);
            list.Add(genre);
            list.Add(genretwo);
            Movie temp = new Movie() { Genres = list, Name = "test", Price = 120d, TrailerURL = "test" };
            temp = facade.GetMovieRepo().Add(temp);

            Assert.GreaterOrEqual(facade.GetGenreRepo().GetGenreByMovie(temp).ToList().Count, 2);
        }
예제 #5
0
        public void Movie_get_all_include_genres_test()
        {
            Facade facade = new Facade();
            Genre genre = new Genre() { Name = "test" };
            List<Genre> list = new List<Genre>();
            genre = facade.GetGenreRepo().Add(genre);
            list.Add(genre);
            Movie temp = new Movie() { Genres = list, Name = "test", Price = 120d, TrailerURL = "test" };
            temp = facade.GetMovieRepo().Add(temp);
            temp = facade.GetMovieRepo().Add(temp);

            facade = new Facade();
            Assert.IsNotNull(facade.GetMovieRepo().GetAll().ElementAt(0).Genres.FirstOrDefault());
            Assert.IsNotNull(facade.GetMovieRepo().GetAll().ElementAt(1).Genres.FirstOrDefault());
        }
예제 #6
0
        public void Order_added_on_create_test()
        {
            Facade facade = new Facade();

            Customer cus = new Customer()
            {
                FirstName = "Test",
                Address = "TestAddress",
                BirthDate = DateTime.Now,
                Email = "TestEmail",
                PhoneNumber = 1234
            };
            cus = facade.GetCustomerRepo().Add(cus);
            Genre genre = new Genre() { Name = "TestGenre" };
            List<Genre> list = new List<Genre>();
            genre = facade.GetGenreRepo().Add(genre);
            list.Add(genre);
            Movie movie = new Movie()
            {
                Name = "TestName",
                Genres = list,
                Price = 123,
                TrailerURL = "TestURL"
            };
            movie = facade.GetMovieRepo().Add(movie);
            Order order = new Order()
            {
                Customer = cus,
                Date = DateTime.Now
            };
            OrderMovie om = new OrderMovie() { Movie = movie, Order = order };
            om = facade.GetOrderMovieRepo().Add(om);

            order.OrderMovie.Add(om);

            order = facade.GetOrderRepo().Add(order);

            facade = new Facade();

            Assert.AreEqual(order.Customer.FirstName, facade.GetOrderRepo().Get(order.Id).Customer.FirstName);
        }
예제 #7
0
        public void Genre_get_by_id_returns_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);

            facade = new Facade();
            Assert.AreEqual(temp.Name, facade.GetGenreRepo().Get(temp.Id).Name);
        }
예제 #8
0
 public void Genre_getgenrebymovie_throws_exception_on_movie_equals_null_test()
 {
     Facade facade = new Facade();
     facade.GetGenreRepo().GetGenreByMovie(null);
 }
예제 #9
0
 public void Genre_add_throws_expection_on_genre_name_equals_null_test()
 {
     Facade facade = new Facade();
     facade.GetGenreRepo().Add(new Genre());
 }
예제 #10
0
        public void Movie_update_updates_in_database_test()
        {
            Facade facade = new Facade();

            Genre genre = new Genre() { Name = "test" };
            List<Genre> list = new List<Genre>();
            genre = facade.GetGenreRepo().Add(genre);
            list.Add(genre);
            Movie temp = new Movie() { Genres = list, Name = "test", Price = 120d, TrailerURL = "test" };
            facade.GetMovieRepo().Add(temp);

            temp.Name = "Changed";

            facade = new Facade();
            Assert.IsTrue(facade.GetMovieRepo().Update(temp));

            facade = new Facade();
            Assert.AreEqual(facade.GetMovieRepo().Get(temp.Id).Name, "Changed");
        }
예제 #11
0
 public void Genre_update_throws_expection_on_genre_name_equals_null_test()
 {
     Facade facade = new Facade();
     Assert.IsFalse(facade.GetGenreRepo().Update(new Genre()));
 }
예제 #12
0
 public void Genre_update_throws_expection_on_genre_equals_null_test()
 {
     Facade facade = new Facade();
     facade.GetGenreRepo().Update(null);
 }
예제 #13
0
 public void Genre_remove_throw_exception_on_null_movie_test()
 {
     Facade facade = new Facade();
     facade.GetGenreRepo().Remove(-1);
 }
예제 #14
0
        public void Movie_get_by_id_includes_genres_test()
        {
            Facade facade = new Facade();
            Genre genre = new Genre() { Name = "test" };
            List<Genre> list = new List<Genre>();
            genre = facade.GetGenreRepo().Add(genre);
            list.Add(genre);
            Movie temp = new Movie() { Genres = list, Name = "test", Price = 120d, TrailerURL = "test" };
            temp = facade.GetMovieRepo().Add(temp);

            facade = new Facade();
            Assert.AreEqual(genre.Name, facade.GetMovieRepo().Get(temp.Id).Genres.FirstOrDefault().Name);
            Assert.AreEqual(genre.Id, facade.GetMovieRepo().Get(temp.Id).Genres.FirstOrDefault().Id);
        }
예제 #15
0
        public void Genre_remove_removing_from_database_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);

            facade = new Facade();
            facade.GetGenreRepo().Remove(temp.Id);

            facade = new Facade();

            Assert.IsNull(facade.GetGenreRepo().Get(temp.Id));
        }
예제 #16
0
        public void Genre_update_updates_in_database_test()
        {
            Genre temp = new Genre() { Name = "test" };

            Facade facade = new Facade();
            facade.GetGenreRepo().Add(temp);

            temp.Name = "Changed";

            facade = new Facade();
            Assert.IsTrue(facade.GetGenreRepo().Update(temp));

            facade = new Facade();
            Assert.AreEqual(facade.GetGenreRepo().Get(temp.Id).Name, "Changed");
        }
예제 #17
0
        public void Movie_get_movie_by_genre_working_test()
        {
            Facade facade = new Facade();

            Movie temp = new Movie() {  Name = "test", Price = 120d, TrailerURL = "test" };
            Movie temp2 = new Movie() {Name = "test2", Price = 120d, TrailerURL = "test" };
            temp = facade.GetMovieRepo().Add(temp);
            temp2 = facade.GetMovieRepo().Add(temp2);

            List<Movie> movies = new List<Movie>() { temp, temp2 };
            Genre genre = new Genre() { Name = "test", Movies = movies };

            genre = facade.GetGenreRepo().Add(genre);

            facade = new Facade();
            Assert.AreEqual(2, facade.GetMovieRepo().GetMovieByGenre(genre).ToList().Count);
        }