コード例 #1
0
 public void Setup()
 {
     _post = PostFactories.Post();
     _post.Publish();
     _post.Withdraw();
     _event = _post.Events.OfType <PostWithdrew>().Single();
 }
コード例 #2
0
        public async Task Setup()
        {
            _post = PostFactories.Post();
            _post.Publish();

            _command = new WithdrawPost
            {
                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 WithdrawPostHandler(_postRepositoryMock.Object);
            _result         = await _commandHandler.HandleAsync(_command);

            _event = _updatedPost.Events.OfType <PostWithdrew>().Single();
        }
コード例 #3
0
 private void Apply(PostWithdrew @event)
 {
     Status          = PostStatus.Draft;
     StatusTimeStamp = @event.TimeStamp;
 }