Exemplo n.º 1
0
        public void ShouldUpdateComment()
        {
            //arrange
            var user = GenerateUser();

            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql);

            dataLayer.AddUser(user);

            var photo = GeneratePhoto(user.Id);

            dataLayer.AddPhoto(photo);

            var comment = GenerateComment(user.Id, photo.Id);

            dataLayer.AddComment(comment);

            var commentUpdate = GenerateComment(user.Id, photo.Id);

            dataLayer.UpdateComment(comment.Id, commentUpdate);
            commentUpdate = dataLayer.GetComment(comment.Id);

            var resComment = dataLayer.GetComment(comment.Id);

            //assert
            Assert.AreEqual(resComment.Id, commentUpdate.Id);
        }
        public void ShouldAddGetDeleteComment()
        {
            //arrange
            var comment = new Comment
            {
                UserId      = Guid.Parse("3c8fddae-8ebc-4cd4-9eb2-30ce678d6c23") /*Guid.NewGuid()*/,
                PostId      = Guid.Parse("82243a65-d1e6-440c-a906-5dffb9cd653c") /*Guid.NewGuid()*/,
                Date        = DateTime.Now,
                CommentText = "This is my comment"/*Guid.NewGuid().ToString()*/
            };
            //act
            var dataLayer  = new DataLayer.Sql.DataLayer(_connectionString);
            var addComment = dataLayer.AddComment(comment);
            var dataLayer1 = new DataLayer.Sql.DataLayer(_connectionString);
            var getComment = dataLayer1.GetComment(addComment.CommentId);
            var dataLayer2 = new DataLayer.Sql.DataLayer(_connectionString);
            int isDeleted  = dataLayer2.DeleteComment(getComment.CommentId);

            //asserts
            Assert.AreEqual(addComment.CommentId, getComment.CommentId);
            Assert.AreEqual(addComment.UserId, getComment.UserId);
            Assert.AreEqual(addComment.PostId, getComment.PostId);
            //Assert.AreEqual(addComment.Date, getComment.Date);
            Assert.AreEqual(addComment.CommentText, getComment.CommentText);
            Assert.IsNotNull(isDeleted);
        }
Exemplo n.º 3
0
        [TestMethod]//ok
        public void AddComTest()
        {
            //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);
            var resultCom = dataLayer.GetComment(com.ComId);

            Assert.AreEqual(com.Text, resultCom.Text);
        }
Exemplo n.º 4
0
        public void ShouldAddComment()
        {
            //arrange
            var user = GenerateUser();

            //act
            var dataLayer = new DataLayer.Sql.DataLayer(ConnectionSql);

            dataLayer.AddUser(user);

            var photo = GeneratePhoto(user.Id);

            dataLayer.AddPhoto(photo);

            var comment = GenerateComment(user.Id, Guid.NewGuid());

            dataLayer.AddComment(comment);

            var resultComment = dataLayer.GetComment(comment.Id);

            //assert
            Assert.AreNotEqual(resultComment.Id, Guid.Empty);
        }