/// <summary>
        ///     Initializes a new instance of the <see cref="MockedKafkaProducer" /> class.
        /// </summary>
        /// <param name="config">
        ///     The producer configuration.
        /// </param>
        /// <param name="topics">
        ///     The collection of <see cref="InMemoryTopic" />.
        /// </param>
        public MockedKafkaProducer(ProducerConfig config, IInMemoryTopicCollection topics)
        {
            Check.NotNull(config, nameof(config));
            _topics = Check.NotNull(topics, nameof(topics));

            Name = $"{config.ClientId ?? "mocked"}.{Guid.NewGuid():N}";
        }
Beispiel #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="KafkaTestingHelper" /> class.
 /// </summary>
 /// <param name="topics">
 ///     The <see cref="IInMemoryTopicCollection" />.
 /// </param>
 /// <param name="outboxReader">
 ///     The <see cref="IOutboxReader" />.
 /// </param>
 /// <param name="logger">
 ///     The <see cref="ISilverbackLogger" />.
 /// </param>
 public KafkaTestingHelper(
     IInMemoryTopicCollection topics,
     IOutboxReader outboxReader,
     ISilverbackIntegrationLogger <KafkaTestingHelper> logger)
 {
     _topics       = topics;
     _outboxReader = outboxReader;
     _logger       = logger;
 }
Beispiel #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MockedKafkaConsumer" /> class.
        /// </summary>
        /// <param name="config">
        ///     The consumer configuration.
        /// </param>
        /// <param name="topics">
        ///     The collection of <see cref="InMemoryTopic" />.
        /// </param>
        public MockedKafkaConsumer(ConsumerConfig config, IInMemoryTopicCollection topics)
        {
            _config = Check.NotNull(config, nameof(config));
            _topics = Check.NotNull(topics, nameof(topics));

            if (string.IsNullOrEmpty(config.GroupId))
            {
                throw new ArgumentException("'group.id' configuration parameter is required and was not specified.");
            }

            Name     = $"{config.ClientId ?? "mocked"}.{Guid.NewGuid():N}";
            GroupId  = config.GroupId;
            MemberId = Guid.NewGuid().ToString("N");

            if (_config.EnableAutoCommit ?? true)
            {
                Task.Run(AutoCommitAsync);
            }
        }
Beispiel #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MockedConfluentProducerBuilder" /> class.
 /// </summary>
 /// <param name="topics">
 ///     The <see cref="IInMemoryTopicCollection" />.
 /// </param>
 public MockedConfluentProducerBuilder(IInMemoryTopicCollection topics)
 {
     _topics = topics;
 }
Beispiel #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MockedConfluentConsumerBuilder" /> class.
 /// </summary>
 /// <param name="topics">
 ///     The <see cref="IInMemoryTopicCollection" />.
 /// </param>
 /// <param name="options">
 ///     The <see cref="IMockedKafkaOptions"/>.
 /// </param>
 public MockedConfluentConsumerBuilder(IInMemoryTopicCollection topics, IMockedKafkaOptions options)
 {
     _topics  = Check.NotNull(topics, nameof(topics));
     _options = Check.NotNull(options, nameof(options));
 }