private void Handle(PostCreated evnt)
 {
     using (var conn = _connectionFactory.OpenConnection())
     {
         conn.Insert(evnt, "EventSourcing_Sample_Post");
     }
 }
Exemple #2
0
 public void When(PostCreated postCreated)
 {
     PostId   = postCreated.PostId;
     AuthorId = postCreated.AuthorId;
     Title    = postCreated.Title;
     Slug     = postCreated.Slug;
 }
Exemple #3
0
 public void Setup()
 {
     _command       = PostFactories.CreatePostCommand();
     _validatorMock = new Mock <IValidator <CreatePost> >();
     _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());
     _post  = new Post(_command, _validatorMock.Object);
     _event = _post.Events.OfType <PostCreated>().Single();
 }
Exemple #4
0
 public async Task <IReadOnlyCollection <IAction> > Handle(PostCreated @event)
 {
     return(new List <IAction> {
         new AddToCategory {
             Id = @event.Id,
             Category = "My Category"
         }
     });
 }
Exemple #5
0
 void IEventHandler <PostCreated> .Handle(PostCreated evnt)
 {
     ParentId  = evnt.ParentId;
     RootId    = evnt.RootId;
     Subject   = evnt.Subject;
     Body      = evnt.Body;
     SectionId = evnt.SectionId;
     AuthorId  = evnt.AuthorId;
     CreatedOn = evnt.CreatedOn;
     UpdatedOn = evnt.CreatedOn;
 }
        public void Process(PostCreated created)
        {
            var post = new Post
            {
                Id    = created.EventSourceId,
                Title = created.Title,
                Body  = created.Body
            };

            InsertEntity(post);
        }
Exemple #7
0
 private void Apply(PostCreated @event)
 {
     Id              = @event.AggregateRootId;
     BlogId          = @event.BlogId;
     Title           = @event.Title;
     Slug            = @event.Slug;
     Excerpt         = @event.Excerpt;
     Content         = @event.Content;
     Tags            = @event.Tags;
     Type            = @event.Type;
     Status          = @event.Status;
     StatusTimeStamp = @event.TimeStamp;
 }
        public async Task Setup()
        {
            _command = PostFactories.CreatePostCommand();

            _validatorMock = new Mock <IValidator <CreatePost> >();
            _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());

            _postRepositoryMock = new Mock <IPostRepository>();
            _postRepositoryMock
            .Setup(x => x.CreateAsync(It.IsAny <Post>()))
            .Callback <Post>(p => _post = p)
            .Returns(Task.CompletedTask);

            _commandHandler = new CreatePostHandler(_postRepositoryMock.Object, _validatorMock.Object);
            _result         = await _commandHandler.HandleAsync(_command);

            _event = _post.Events.OfType <PostCreated>().Single();
        }
 protected virtual void Handle(PostCreated evnt)
 {
     _entityManager.BuildAndSave<PostEntity>(evnt);
 }
Exemple #10
0
 private void OnPostCreated(Post post)
 {
     // Check if there is any subscriber, then invoke
     PostCreated?.Invoke(this, new PostEventArgs(post));
 }
Exemple #11
0
 public void Apply(PostCreated evt)
 {
     Id = evt.PostId;
 }
Exemple #12
0
 protected virtual void Handle(PostCreated evnt)
 {
     _entityManager.BuildAndSave <PostEntity>(evnt);
 }
Exemple #13
0
 public void CreatePost(Post post)
 {
     _posts.Add(post);
     PostCreated?.Invoke(post);
 }
Exemple #14
0
 public When_initializing()
 {
     _sut = new PostCreated(_post);
 }
Exemple #15
0
 public void Handle(PostCreated evnt)
 {
     PostTest.PostId = evnt.PostId;
     TestBase.EventHandlerWaiter.Set();
 }