예제 #1
0
        public async Task ItShouldCompleteSuccessfully()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.InitializeTarget(testDatabase);
                await this.CreateEntitiesAsync(testDatabase);
                await testDatabase.TakeSnapshotAsync();

                var expectedInsert = new Persistence.Comment
                {
                    Id           = CommentId.Value,
                    PostId       = PostId.Value,
                    UserId       = UserId.Value,
                    Content      = Comment.Value,
                    CreationDate = Timestamp,
                };

                await this.target.ExecuteAsync(UserId, PostId, CommentId, Comment, Timestamp);

                return(new ExpectedSideEffects
                {
                    Insert = expectedInsert,
                });
            });
        }
 private CommentsResult.Item GetCommentsResultItem(Persistence.Comment comment, FifthweekUser user)
 {
     return(new CommentsResult.Item(
                new CommentId(comment.Id),
                new PostId(comment.PostId),
                new UserId(comment.UserId),
                new Username(user.UserName),
                new Shared.Comment(comment.Content),
                comment.CreationDate));
 }
        public async Task ExecuteAsync(UserId userId, PostId postId, CommentId commentId, Shared.Comment content, DateTime timestamp)
        {
            userId.AssertNotNull("userId");
            postId.AssertNotNull("postId");
            commentId.AssertNotNull("commentId");
            content.AssertNotNull("content");

            var comment = new Persistence.Comment(commentId.Value, postId.Value, null, userId.Value, null, content.Value, timestamp);

            using (var connection = this.connectionFactory.CreateConnection())
            {
                await connection.UpsertAsync(
                    comment,
                    Persistence.Comment.Fields.PostId
                    | Persistence.Comment.Fields.UserId
                    | Persistence.Comment.Fields.Content
                    | Persistence.Comment.Fields.CreationDate);
            }
        }