public void OrderMovie_get_all_return_multiple_test() { Facade facade = new Facade(); Movie mov = facade.GetMovieRepo().Add(SetMovie()); Order or1 = facade.GetOrderRepo().Add(SetOrder()); Order or2 = facade.GetOrderRepo().Add(SetOrder()); OrderMovie om = new OrderMovie() { Movie = mov, Order = or1 }; OrderMovie om2 = new OrderMovie() { Movie = mov, Order = or2 }; facade.GetOrderMovieRepo().Add(om); facade.GetOrderMovieRepo().Add(om); facade = new Facade(); Assert.GreaterOrEqual(facade.GetOrderMovieRepo().GetAll().ToList().Count, 2); }
public void OrderMovie_get_movie_by_om_returning_movie_test() { Facade facade = new Facade(); Movie mov = facade.GetMovieRepo().Add(SetMovie()); Order or1 = facade.GetOrderRepo().Add(SetOrder()); OrderMovie om = new OrderMovie() { Movie = mov, Order = or1 }; om = facade.GetOrderMovieRepo().Add(om); facade = new Facade(); Assert.AreEqual(facade.GetOrderMovieRepo().GetMovieByOrderMovie(om).Name, mov.Name); }
public void OrderMovie_getall_oms_by_order_test() { Facade facade = new Facade(); Movie mov = facade.GetMovieRepo().Add(SetMovie()); Movie mov2 = SetMovie(); mov2.Name = "changed"; mov2 = facade.GetMovieRepo().Add(mov2); Order or1 = facade.GetOrderRepo().Add(SetOrder()); OrderMovie om = new OrderMovie() { Movie = mov, Order = or1 }; OrderMovie om2 = new OrderMovie() { Movie = mov2, Order = or1 }; om = facade.GetOrderMovieRepo().Add(om); om2 = facade.GetOrderMovieRepo().Add(om2); facade = new Facade(); Assert.GreaterOrEqual(facade.GetOrderMovieRepo().GetAllOrderMoviesByOrder(or1).ToList().Count, 2); }
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); }
public void OrderMovie_remove_removes_from_db_test() { Facade facade = new Facade(); Movie mov = facade.GetMovieRepo().Add(SetMovie()); Order or1 = facade.GetOrderRepo().Add(SetOrder()); OrderMovie om = new OrderMovie() { Movie = mov, Order = or1 }; om = facade.GetOrderMovieRepo().Add(om); facade = new Facade(); facade.GetOrderMovieRepo().Remove(om.Id); facade = new Facade(); Assert.IsNull(facade.GetOrderMovieRepo().Get(om.Id)); }
public void OrderMovie_update_updates_in_db_test() { Facade facade = new Facade(); Movie mov = facade.GetMovieRepo().Add(SetMovie()); Movie mov2 = SetMovie(); mov2.Name = "changed"; mov2 = facade.GetMovieRepo().Add(mov2); Order or1 = facade.GetOrderRepo().Add(SetOrder()); OrderMovie om = new OrderMovie() { Movie = mov, Order = or1 }; om = facade.GetOrderMovieRepo().Add(om); facade = new Facade(); om.Movie = mov2; Assert.IsTrue(facade.GetOrderMovieRepo().Update(om)); facade = new Facade(); Assert.AreEqual(mov2.Name, facade.GetOrderMovieRepo().Get(om.Id).Movie.Name); }
public void Order_add_throws_exception_on_order_equals_null_test() { Facade facade = new Facade(); facade.GetOrderRepo().Add(null); }
public void Order_update_updates_in_database_test() { Facade facade = new Facade(); Order order = new Order() { Date = DateTime.Now, Customer = new Customer() { BirthDate = DateTime.Now, FirstName = "jonas" }, OrderMovie = new List<OrderMovie>() }; order = facade.GetOrderRepo().Add(order); order.Customer = new Customer() { BirthDate = DateTime.Now, FirstName = "hans" }; facade = new Facade(); Assert.IsTrue(facade.GetOrderRepo().Update(order)); facade = new Facade(); Assert.AreEqual(facade.GetOrderRepo().Get(order.Id).Customer.FirstName, "hans"); }
public void Order_update_throws_exception_on_order_equals_null_test() { Facade facade = new Facade(); facade.GetOrderRepo().Update(null); }
public void Order_update_returns_false_on_order_not_exists_test() { Facade facade = new Facade(); Assert.IsFalse(facade.GetOrderRepo().Update(new Order())); }
public void Order_remove_throws_exception_on_order_equals_null_test() { Facade facade = new Facade(); facade.GetOrderRepo().Remove(-1); }
public void Order_getorderbycustomer_throws_exception_on_customer_equals_null_test() { Facade facade = new Facade(); facade.GetOrderRepo().GetOrdersByCustomer(null); }
public void Order_getorderbycustomer_returns_multiple_test() { Facade facade = new Facade(); Customer cus = new Customer() { BirthDate = DateTime.Now, FirstName = "jonas", Address ="hest", Email = "hest" }; cus = facade.GetCustomerRepo().Add(cus); Order orderOne = new Order() { Customer = cus, Date = DateTime.Now, OrderMovie = new List<OrderMovie>() }; Order orderTwo = new Order() { Customer = cus, Date = DateTime.Now, OrderMovie = new List<OrderMovie>() }; orderOne = facade.GetOrderRepo().Add(orderOne); orderTwo = facade.GetOrderRepo().Add(orderTwo); facade = new Facade(); Assert.GreaterOrEqual(facade.GetOrderRepo().GetOrdersByCustomer(cus).ToList().Count, 2); }
public void Order_getmoviesbyorder_throws_exception_on_order_equals_null_test() { Facade facade = new Facade(); facade.GetOrderRepo().GetMoviesByOrder(null); }
public void Order_getmoviesbyorder_returns_multiple_right_movies_test() { Facade facade = new Facade(); Movie movieOne = new Movie() { Year = DateTime.Now, Name = "mov1" }; Movie movieTwo = new Movie() { Year = DateTime.Now, Name = "mov2" }; List<OrderMovie> list = new List<OrderMovie>(); list.Add(new OrderMovie() { Movie = movieOne }); list.Add(new OrderMovie() { Movie = movieTwo }); Order order = new Order() { Date = DateTime.Now, OrderMovie = list, Customer = new Customer() { BirthDate = DateTime.Now} }; order = facade.GetOrderRepo().Add(order); facade = new Facade(); Assert.GreaterOrEqual(facade.GetOrderRepo().GetMoviesByOrder(order).ToList().Count, 2); Assert.AreEqual(facade.GetOrderRepo().GetMoviesByOrder(order).FirstOrDefault().Name, movieOne.Name); }