Beispiel #1
0
        public void Test_dataAdapter_delete_article()
        {
            // Arrange
            utils.CleanTables();
            Tuple <string, string> userIds = utils.CreateUsers();
            int articleId = utils.CreateSingleArticle(userIds.Item2);

            utils.AddLike(userIds.Item2, articleId);
            IDataAccessAdapter adapter = container.Resolve <IDataAccessAdapter>();
            Article            article = adapter.GetEntities <Article>().SingleOrDefault(n => n.Id == articleId);

            // Act
            article.Likes.Select(l => adapter.Remove(l));
            //for (int i = 0; i < article.Likes.Count(); i++)
            //{
            //    adapter.Remove(article.Likes.ElementAt(i));
            //}
            Article deletedArticle = adapter.Remove(article);

            adapter.SaveChanges();
            IEnumerable <Article> articlees = adapter.GetEntities <Article>();

            // Assert
            Assert.IsNotNull(deletedArticle);
            Assert.AreEqual(0, articlees.Count());
        }
        public void Test_dataAdapter_delete_user_and_otp()
        {
            // Arrange
            CleanTables();
            CreateOtp(CreateUser());
            IDataAccessAdapter adapter = container.Resolve <IDataAccessAdapter>();

            // Act
            List <User> userList = adapter.GetEntities <User>().ToList();
            User        user     = userList.First();

            adapter.Remove(user.Otp);
            adapter.Remove(user);
            adapter.SaveChanges();
            List <User> users = adapter.GetEntities <User>().ToList();
            List <Otp>  otps  = adapter.GetEntities <Otp>().ToList();

            // Assert
            Assert.IsTrue(users.Count() == 0);
            Assert.IsTrue(otps.Count() == 0);
        }
Beispiel #3
0
        public void Test_dataAdapter_remove_like()
        {
            // Arrange
            utils.CleanTables();
            Tuple <string, string> userIds = utils.CreateUsers();
            int articleId = utils.CreateSingleArticle(userIds.Item2);
            int likeId    = utils.AddLike(userIds.Item1, articleId);
            IDataAccessAdapter adapter = container.Resolve <IDataAccessAdapter>();
            Article            article = adapter.GetEntities <Article>().SingleOrDefault(n => n.Id == articleId);
            Like like = article.Likes.Single(l => l.Id == likeId);

            // Act
            adapter.Remove(like);
            adapter.SaveChanges();
            Article modifiedArticle = adapter.GetEntities <Article>().SingleOrDefault(n => n.Id == articleId);

            // Assert
            Assert.IsNotNull(modifiedArticle);
            Assert.IsTrue(modifiedArticle.Likes.Count() == 0);
        }
Beispiel #4
0
 public virtual TEntity Remove(TEntity entity)
 {
     return(_dataAccessAdapter.Remove(entity));
 }