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(); } } }
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); }
private void WaitUntilCommentDeleted(PostComment comment) { var repo = GetRepo(); Helpers.WaitUntil(() => !repo.GetComments().Any(x => x.Id == comment.Id), MaxTimeoutSeconds); }
private void WaitUntilCommentAdded(PostComment comment) { var repo = GetRepo(); Helpers.WaitUntil(() => repo.GetComments().Any(x => x.Text == comment.Text), MaxTimeoutSeconds); }
public void DeleteComment(PostComment comment) { client.DeleteComment(comment.ToDto()); }
public void AddComment(PostComment comment) { client.AddComment(comment.ToDto()); }