Exemplo n.º 1
0
        [TestMethod]//ok
        public void DeleteComTest()
        {
            //firstly, add user to add him post
            var user = new Users
            {
                Nickname = Guid.NewGuid().ToString().Substring(10),
                Username = Guid.NewGuid().ToString().Substring(10),
                Info     = Guid.NewGuid().ToString().Substring(10)
            };
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionString);

            user = dataLayer.AddUser(user);
            //add post to user
            var post = new Posts
            {
                UserId = user.UserId,
                Date   = DateTime.Now,
                Photo  = Guid.NewGuid().ToString().Substring(10)
            };

            post = dataLayer.AddPost(post);
            //add com to post
            var com = new Comments()
            {
                Date   = DateTime.Now,
                FromId = user.UserId,
                PostId = post.PostId,
                Text   = Guid.NewGuid().ToString().Substring(10)
            };

            dataLayer.AddCommentToPost(post.PostId, com);
            dataLayer.DeleteComment(com.ComId);
            Assert.AreEqual(dataLayer.IsComment(com.ComId), false);
        }