Ejemplo n.º 1
0
        public async Task WhenPostingComment_ItShouldIssuePostCommentCommand()
        {
            var commentId = CommentId.Random();
            var content   = ValidComment.Parse("This is a valid comment");
            var timestamp = DateTime.UtcNow;

            this.guidCreator.Setup(v => v.CreateSqlSequential()).Returns(commentId.Value);
            this.timestampCreator.Setup(v => v.Now()).Returns(timestamp);
            this.requesterContext.Setup(_ => _.GetRequesterAsync()).ReturnsAsync(Requester);
            this.postComment.Setup(v => v.HandleAsync(new CommentOnPostCommand(Requester, PostId, commentId, content, timestamp)))
            .Returns(Task.FromResult(0))
            .Verifiable();

            await this.target.PostComment(PostId.Value.EncodeGuid(), new CommentData(content.Value));

            this.postComment.Verify();
        }
Ejemplo n.º 2
0
        public async Task WhenPostingFeedback_ItShouldIssueSubmitFeedbackCommand()
        {
            var requester = Requester.Authenticated(UserId.Random());

            this.requesterContext.Setup(v => v.GetRequesterAsync()).ReturnsAsync(requester);

            var registration = NewFeedbackData();
            var command      = new SubmitFeedbackCommand(
                requester,
                ValidComment.Parse(registration.Message));

            this.registerInterest.Setup(v => v.HandleAsync(command)).Returns(Task.FromResult(0));

            var result = await this.controller.PostFeedbackAsync(registration);

            Assert.IsInstanceOfType(result, typeof(OkResult));
            this.registerInterest.Verify(v => v.HandleAsync(command));
        }