public void ProduceRequest( [Values(0, 1, 2)] short version, [Values(0, 2, -1)] short acks, [Values(0, 1000)] int timeoutMilliseconds, [Values("testTopic")] string topic, [Values(1, 10)] int topicsPerRequest, [Values(1, 5)] int totalPartitions, [Values(3)] int messagesPerSet, [Values(MessageCodec.None, MessageCodec.Gzip, MessageCodec.Snappy)] MessageCodec codec) { #if !DOTNETSTANDARD if (codec == MessageCodec.Snappy) { Assert.Inconclusive($"{codec} is only available in .net core"); } #endif var payloads = new List <ProduceRequest.Topic>(); for (var t = 0; t < topicsPerRequest; t++) { var partition = 1 + t % totalPartitions; payloads.Add(new ProduceRequest.Topic(topic + t, partition, GenerateMessages(messagesPerSet, (byte)(version >= 2 ? 1 : 0), codec), codec)); } var request = new ProduceRequest(payloads, TimeSpan.FromMilliseconds(timeoutMilliseconds), acks); var requestWithUpdatedAttribute = new ProduceRequest(request.topics.Select(t => new ProduceRequest.Topic(t.topic, t.partition_id, t.Messages.Select(m => m.Attribute == 0 ? m : new Message(m.Value, m.Key, 0, m.Offset, m.MessageVersion, m.Timestamp)))), request.timeout, request.acks); request.AssertCanEncodeDecodeRequest(version, forComparison: requestWithUpdatedAttribute); }
public void ProduceRequest( [Values(0, 1, 2)] short version, [Values(0, 2, -1)] short acks, [Values(0, 1000)] int timeoutMilliseconds, [Values("test", "a really long name, with spaces and punctuation!")] string topic, [Values(1, 10)] int topicsPerRequest, [Values(1, 5)] int totalPartitions, [Values(3)] int messagesPerSet) { var payloads = new List <ProduceRequest.Payload>(); for (var t = 0; t < topicsPerRequest; t++) { var partition = 1 + t % totalPartitions; payloads.Add(new ProduceRequest.Payload(topic + t, partition, GenerateMessages(messagesPerSet, (byte)(version >= 2 ? 1 : 0), partition))); } var request = new ProduceRequest(payloads, TimeSpan.FromMilliseconds(timeoutMilliseconds), acks); request.AssertCanEncodeDecodeRequest(version); }