コード例 #1
0
ファイル: TestRepository.cs プロジェクト: drypa/BlogSample_v2
        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
ファイル: BlogFixture.cs プロジェクト: drypa/BlogSample_v2
        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
ファイル: BlogFixture.cs プロジェクト: drypa/BlogSample_v2
 private void WaitUntilCommentDeleted(PostComment comment)
 {
     var repo = GetRepo();
     Helpers.WaitUntil(() => !repo.GetComments().Any(x => x.Id == comment.Id), MaxTimeoutSeconds);
 }
コード例 #4
0
ファイル: BlogFixture.cs プロジェクト: drypa/BlogSample_v2
 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());
 }