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(); }
public void When(PostPublished postPublished) { Published = postPublished.Published; }
private void Apply(PostPublished @event) { Status = PostStatus.Published; StatusTimeStamp = @event.TimeStamp; }
public void Setup() { _post = PostFactories.Post(); _post.Publish(); _event = _post.Events.OfType <PostPublished>().Single(); }