예제 #1
0
        public void AddComment(PostComment comment)
        {
            using (var connection = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = connection.CreateCommand())
                {
                    connection.Open();
                    cmd.CommandText = @"INSERT INTO [dbo].[Comment]
                                           ([Id]
                                           ,[CreateDate]
                                           ,[Post]
                                           ,[Text])
                                     VALUES
                                           (@id
                                           ,@date
                                           ,@postId
                                           ,@text)";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value = comment.Id;
                    cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = comment.CreationDate;
                    cmd.Parameters.Add("@text", SqlDbType.VarChar, 200).Value = comment.Text;
                    cmd.Parameters.Add("@postId", SqlDbType.UniqueIdentifier).Value = comment.Post.Id;

                    cmd.ExecuteNonQuery();
                }
            }
        }
예제 #2
0
        public void DeleteComment()
        {
            PostDetails post = CreatePost();
            var repository = GetTestRepository();
            var comment = new PostComment
            {
                Id = Guid.NewGuid(),
                Post = post,
                Text = commentText,
                CreationDate = DateTime.Now
            };
            repository.AddPost(post);
            repository.AddComment(comment);

            var client = GetClient();
            client.DeleteComment(comment);
            WaitUntilCommentDeleted(comment);
        }
예제 #3
0
 private void WaitUntilCommentDeleted(PostComment comment)
 {
     var repo = GetRepo();
     Helpers.WaitUntil(() => !repo.GetComments().Any(x => x.Id == comment.Id), MaxTimeoutSeconds);
 }
예제 #4
0
 private void WaitUntilCommentAdded(PostComment comment)
 {
     var repo = GetRepo();
     Helpers.WaitUntil(() => repo.GetComments().Any(x => x.Text == comment.Text), MaxTimeoutSeconds);
 }
예제 #5
0
 public void DeleteComment(PostComment comment)
 {
     client.DeleteComment(comment.ToDto());
 }
예제 #6
0
 public void AddComment(PostComment comment)
 {
     client.AddComment(comment.ToDto());
 }