コード例 #1
0
        public void Publish_SendsUserSubscribedEvent_ToEventSourcingTopic_AndPublicTopic()
        {
            //Arrange
            Event subscription   = fixture.Create <UserSubscribed>();
            Event passwordChange = fixture.Create <PasswordChanged>();

            //Act
            eventPublisher.Publish(new[] { subscription, passwordChange }).Wait();

            //Assert
            eventSerializer.Received(1).Serialize(Arg.Any <UserSubscribed>());

            producer.Received(1).ProduceAsync(
                Arg.Is(KafkaTopics.UserEventSourcing),
                Arg.Is <Message <string, string> >(
                    m => m.Key == subscription.AggregateId.ToString() &&
                    !string.IsNullOrEmpty(m.Value)
                    )
                );

            producer.Received(1).ProduceAsync(
                Arg.Is(KafkaTopics.UserPublicEvents),
                Arg.Is <Message <string, string> >(
                    m => m.Key == subscription.AggregateId.ToString() &&
                    !string.IsNullOrEmpty(m.Value)
                    )
                );

            producer.Received(1).ProduceAsync(
                Arg.Is(KafkaTopics.UserEventSourcing),
                Arg.Is <Message <string, string> >(
                    m => m.Key == passwordChange.AggregateId.ToString() &&
                    !string.IsNullOrEmpty(m.Value)
                    )
                );
        }