Exemplo n.º 1
0
        public void TestRepositoryAddMultipleReviews()
        {
            Review review = new Review(reviewTest.User, reviewTest.Product, "Descripcion de la review", 8);

            reviewRepository.AddEntity(reviewTest);
            reviewRepository.AddEntity(review);

            List <Review> list = reviewRepository.GetAllEntities();

            Assert.IsTrue(list.Contains(reviewTest) && list.Contains(review));
        }
        private static void CleanReview(ReviewRepository repository)
        {
            var entities = repository.GetAllEntities();

            foreach (Review entity in entities)
            {
                using (var db = new ESportDbContext())
                    try
                    {
                        var entityToRemove = db.Review.Attach(entity);
                        db.Review.Remove(entityToRemove);
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        throw new RepositoryException("Error al eliminar entidad", e);
                    }
            }
        }