public async Task Setup()
        {
            _post = PostFactories.Post();

            _command = new PublishPost
            {
                BlogId          = Guid.NewGuid(),
                AggregateRootId = Guid.NewGuid()
            };

            _postRepositoryMock = new Mock <IPostRepository>();
            _postRepositoryMock
            .Setup(x => x.GetByIdAsync(_command.BlogId, _command.AggregateRootId))
            .ReturnsAsync(_post);
            _postRepositoryMock
            .Setup(x => x.UpdateAsync(It.IsAny <Post>()))
            .Callback <Post>(p => _updatedPost = p)
            .Returns(Task.CompletedTask);

            _commandHandler = new PublishPostHandler(_postRepositoryMock.Object);
            _result         = await _commandHandler.HandleAsync(_command);

            _event = _updatedPost.Events.OfType <PostPublished>().Single();
        }
Example #2
0
 public void When(PostPublished postPublished)
 {
     Published = postPublished.Published;
 }
Example #3
0
 private void Apply(PostPublished @event)
 {
     Status          = PostStatus.Published;
     StatusTimeStamp = @event.TimeStamp;
 }
Example #4
0
 public void Setup()
 {
     _post = PostFactories.Post();
     _post.Publish();
     _event = _post.Events.OfType <PostPublished>().Single();
 }