public async Task ElasticSearchNotiferShouldIndexMessage()
        {
            //Arrange
            var eventStore = new EventStore(Guid.NewGuid(),
                                            It.IsAny <long>(), It.IsAny <string>(), "type", DateTime.Now, "body");
            var message = new NotificationMessage <string> {
                Message = "notifyText"
            };

            var @event = new SpeechTitleChangedEvent(Guid.NewGuid(), "title");
            var mockEventSerializer = new Mock <IEventSerializer>();

            mockEventSerializer.Setup(m => m.Deserialize <Event>(It.IsAny <string>(), It.IsAny <string>())).Returns(@event);

            var mockJsonSerializer = new Mock <IJsonSerializer>();

            mockJsonSerializer.Setup(m => m.Deserialize <EventStore>(It.IsAny <string>()))
            .Returns(eventStore);

            var mockElasticSearchClient = new Mock <IElasticSearchClient <SpeechProjection> >();

            mockElasticSearchClient.Setup(m => m.CreateAsync(It.IsAny <SpeechProjection>())).Verifiable();

            var mockSignalRPublisher = new Mock <ISignalRPublisher>();

            mockSignalRPublisher.Setup(m => m.PublishAsync(It.IsAny <string>(), It.IsAny <SpeechProjection>())).Verifiable();

            //Act
            INotificationHandler <NotificationMessage <string> > elasticSearchNotifer = new ElasticSearchNotifer(mockEventSerializer.Object, mockJsonSerializer.Object, mockElasticSearchClient.Object, mockSignalRPublisher.Object);
            await elasticSearchNotifer.Handle(message, CancellationToken.None);

            //Assert
            mockElasticSearchClient.Verify(m => m.CreateAsync(It.IsAny <SpeechProjection>()), Times.Once);
            mockSignalRPublisher.Verify(m => m.PublishAsync(It.IsAny <string>(), It.IsAny <SpeechProjection>()), Times.Once);
        }
 public void Apply(SpeechTitleChangedEvent ev)
 {
     if (ev.AggregateId != Id)
     {
         throw new InvalidDomainEventException(ErrorCode.InvalidDomainEvent, $"Cannot apply event : Speech Id ({Id}) is not equals to AggregateId ({ev.AggregateId}) of the event , {nameof(SpeechTitleChangedEvent)}");
     }
     _title = ev.Title;
 }
        public void ShouldApplySpeechTitleChangedEvent()
        {
            //Arrange
            var speechProjection        = Invoker.CreateInstanceOfProjection <SpeechProjection>();
            var speechTitleChangedEvent = new SpeechTitleChangedEvent(Guid.NewGuid(), "my title");

            //Act
            speechProjection.Apply(speechTitleChangedEvent);

            //Assert
            Assert.Equal(speechTitleChangedEvent.AggregateId, speechProjection.Id);
            Assert.Equal(speechTitleChangedEvent.Title, speechProjection.Title);
            Assert.Equal(default, speechProjection.Description);
 public void Apply(SpeechTitleChangedEvent ev)
 {
     _title = ev.Title;
 }
 public void Apply(SpeechTitleChangedEvent ev)
 {
     Id    = ev.AggregateId;
     Title = ev.Title;
 }