public void Setup() { _post = PostFactories.Post(); _post.Delete(); _post.Restore(); _event = _post.Events.OfType <PostRestored>().Single(); }
public async Task Setup() { _post = PostFactories.Post(); _post.Delete(); _command = new RestorePost { 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 RestorePostHandler(_postRepositoryMock.Object); _result = await _commandHandler.HandleAsync(_command); _event = _updatedPost.Events.OfType <PostRestored>().Single(); }
private void Apply(PostRestored @event) { Status = PostStatus.Draft; StatusTimeStamp = @event.TimeStamp; }